Fixed #32 - PlayAlertSound ignored on Paste Block Style
This commit is contained in:
parent
0b791f5747
commit
af08cdfed6
|
@ -9,6 +9,6 @@ namespace Filtration.Parser.Interface.Services
|
||||||
IItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
|
IItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
|
||||||
ThemeComponentCollection masterComponentCollection);
|
ThemeComponentCollection masterComponentCollection);
|
||||||
string TranslateItemFilterBlockToString(IItemFilterBlock block);
|
string TranslateItemFilterBlockToString(IItemFilterBlock block);
|
||||||
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1472,7 +1472,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlock()
|
public void ReplaceAudioVisualBlockItemsFromString_SingleLine_ReplacesColorBlock()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
|
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
|
||||||
|
@ -1482,7 +1482,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
testInputBlockItems.Add(testInputBlockItem);
|
testInputBlockItems.Add(testInputBlockItem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
||||||
|
@ -1492,7 +1492,28 @@ namespace Filtration.Parser.Tests.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlockBugTest()
|
public void ReplaceAudioVisualBlockItemsFromString_SingleLine_ReplacesSoundBlockItem()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputString = "PlayAlertSound 7 280";
|
||||||
|
|
||||||
|
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||||
|
var testInputBlockItem = new SoundBlockItem(12,30);
|
||||||
|
testInputBlockItems.Add(testInputBlockItem);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var soundBlockItem = testInputBlockItems.First(b => b is SoundBlockItem) as SoundBlockItem;
|
||||||
|
Assert.IsNotNull(soundBlockItem);
|
||||||
|
Assert.AreNotSame(testInputBlockItem, soundBlockItem);
|
||||||
|
Assert.AreEqual(7, soundBlockItem.Value);
|
||||||
|
Assert.AreEqual(280, soundBlockItem.SecondValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReplaceAudioVisualBlockItemsFromString_SingleLine_ReplacesColorBlockBugTest()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var testInputString = "SetBackgroundColor 70 0 0 255";
|
var testInputString = "SetBackgroundColor 70 0 0 255";
|
||||||
|
@ -1502,7 +1523,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
testInputBlockItems.Add(testInputBlockItem);
|
testInputBlockItems.Add(testInputBlockItem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
|
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
|
||||||
|
@ -1513,7 +1534,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
|
|
||||||
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
|
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
|
public void ReplaceAudioVisualBlockItemsFromString_MalformedLine_DoesNothing()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var testInputString = "SetTextCsaolor 240 200 150 # Rarest Currency";
|
var testInputString = "SetTextCsaolor 240 200 150 # Rarest Currency";
|
||||||
|
@ -1523,7 +1544,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
testInputBlockItems.Add(testInputBlockItem);
|
testInputBlockItems.Add(testInputBlockItem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
||||||
|
@ -1532,23 +1553,27 @@ namespace Filtration.Parser.Tests.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_MultipleLines_ExistingBlockItems()
|
public void ReplaceAudioVisualBlockItemsFromString_MultipleLines_ExistingBlockItems()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
|
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
|
||||||
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
|
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
|
||||||
"SetBorderColor 255 255 255 # Rarest Currency Border";
|
"SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine +
|
||||||
|
"PlayAlertSound 7 280";
|
||||||
|
|
||||||
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||||
var testInputTextColorBlockItem = new TextColorBlockItem(Colors.Red);
|
var testInputTextColorBlockItem = new TextColorBlockItem(Colors.Red);
|
||||||
var testInputBackgroundColorBlockItem = new BackgroundColorBlockItem(Colors.Blue);
|
var testInputBackgroundColorBlockItem = new BackgroundColorBlockItem(Colors.Blue);
|
||||||
var testInpuBorderColorBlockItem = new BorderColorBlockItem(Colors.Yellow);
|
var testInputBorderColorBlockItem = new BorderColorBlockItem(Colors.Yellow);
|
||||||
|
var testInputSoundBlockItem = new SoundBlockItem(1, 1);
|
||||||
|
|
||||||
testInputBlockItems.Add(testInputTextColorBlockItem);
|
testInputBlockItems.Add(testInputTextColorBlockItem);
|
||||||
testInputBlockItems.Add(testInputBackgroundColorBlockItem);
|
testInputBlockItems.Add(testInputBackgroundColorBlockItem);
|
||||||
testInputBlockItems.Add(testInpuBorderColorBlockItem);
|
testInputBlockItems.Add(testInputBorderColorBlockItem);
|
||||||
|
testInputBlockItems.Add(testInputSoundBlockItem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
||||||
|
@ -1563,23 +1588,29 @@ namespace Filtration.Parser.Tests.Services
|
||||||
|
|
||||||
var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem;
|
var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem;
|
||||||
Assert.IsNotNull(borderColorBlockItem);
|
Assert.IsNotNull(borderColorBlockItem);
|
||||||
Assert.AreNotSame(testInpuBorderColorBlockItem, borderColorBlockItem);
|
Assert.AreNotSame(testInputBorderColorBlockItem, borderColorBlockItem);
|
||||||
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
|
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
|
||||||
|
|
||||||
|
var soundBlockItem = testInputBlockItems.First(b => b is SoundBlockItem) as SoundBlockItem;
|
||||||
|
Assert.IsNotNull(soundBlockItem);
|
||||||
|
Assert.AreNotSame(testInputSoundBlockItem, soundBlockItem);
|
||||||
|
Assert.AreEqual(7, soundBlockItem.Value);
|
||||||
|
Assert.AreEqual(280, soundBlockItem.SecondValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_MultipleLines_NoExistingBlockItems()
|
public void ReplaceAudioVisualBlockItemsFromString_MultipleLines_NoExistingBlockItems()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
|
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
|
||||||
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
|
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
|
||||||
"SetBorderColor 255 255 255 # Rarest Currency Border";
|
"SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine +
|
||||||
|
"PlayAlertSound 7 280";
|
||||||
|
|
||||||
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
||||||
|
@ -1593,10 +1624,15 @@ namespace Filtration.Parser.Tests.Services
|
||||||
var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem;
|
var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem;
|
||||||
Assert.IsNotNull(borderColorBlockItem);
|
Assert.IsNotNull(borderColorBlockItem);
|
||||||
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
|
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
|
||||||
|
|
||||||
|
var soundBlockItem = testInputBlockItems.First(b => b is SoundBlockItem) as SoundBlockItem;
|
||||||
|
Assert.IsNotNull(soundBlockItem);
|
||||||
|
Assert.AreEqual(7, soundBlockItem.Value);
|
||||||
|
Assert.AreEqual(280, soundBlockItem.SecondValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_MultipleLines_SomeExistingBlockItems()
|
public void ReplaceAudioVisualBlockItemsFromString_MultipleLines_SomeExistingBlockItems()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
|
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
|
||||||
|
@ -1611,7 +1647,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
testInputBlockItems.Add(testInpuBorderColorBlockItem);
|
testInputBlockItems.Add(testInpuBorderColorBlockItem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
|
||||||
|
@ -1627,7 +1663,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
|
|
||||||
[Ignore("ThemeComponentBuilder deprecated")]
|
[Ignore("ThemeComponentBuilder deprecated")]
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
|
public void ReplaceAudioVisualBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
|
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
|
||||||
|
@ -1637,7 +1673,7 @@ namespace Filtration.Parser.Tests.Services
|
||||||
testInputBlockItems.Add(testInputBlockItem);
|
testInputBlockItems.Add(testInputBlockItem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
|
|
|
@ -318,7 +318,7 @@ namespace Filtration.Parser.Services
|
||||||
return blockItem;
|
return blockItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
|
public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
|
||||||
{
|
{
|
||||||
// Reverse iterate to remove existing IAudioVisualBlockItems
|
// Reverse iterate to remove existing IAudioVisualBlockItems
|
||||||
for (var idx = blockItems.Count - 1; idx >= 0; idx--)
|
for (var idx = blockItems.Count - 1; idx >= 0; idx--)
|
||||||
|
@ -335,6 +335,13 @@ namespace Filtration.Parser.Services
|
||||||
|
|
||||||
switch (matches.Value)
|
switch (matches.Value)
|
||||||
{
|
{
|
||||||
|
case "PlayAlertSound":
|
||||||
|
{
|
||||||
|
var match = Regex.Match(line, @"\s+(\d+) (\d+)");
|
||||||
|
if (!match.Success) break;
|
||||||
|
blockItems.Add(new SoundBlockItem(Convert.ToInt16(match.Groups[1].Value), Convert.ToInt16(match.Groups[2].Value)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "SetTextColor":
|
case "SetTextColor":
|
||||||
{
|
{
|
||||||
blockItems.Add(GetColorBlockItemFromString<TextColorBlockItem>(line));
|
blockItems.Add(GetColorBlockItemFromString<TextColorBlockItem>(line));
|
||||||
|
|
|
@ -605,7 +605,7 @@ namespace Filtration.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_blockTranslator.ReplaceColorBlockItemsFromString(targetBlockViewModel.Block.BlockItems, clipboardText);
|
_blockTranslator.ReplaceAudioVisualBlockItemsFromString(targetBlockViewModel.Block.BlockItems, clipboardText);
|
||||||
targetBlockViewModel.RefreshBlockPreview();
|
targetBlockViewModel.RefreshBlockPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue