Fixed single line script description bug

Style tweaks inc. block selection style
This commit is contained in:
Ben
2015-06-28 22:46:29 +01:00
parent c3a40b3412
commit 3a628df744
10 changed files with 115 additions and 25 deletions

View File

@@ -1346,6 +1346,7 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color);
}
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
[Test]
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
{
@@ -1409,8 +1410,9 @@ namespace Filtration.Tests.Translators
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
@@ -1428,6 +1430,36 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
}
[Test]
public void ReplaceColorBlockItemsFromString_MultipleLines_SomeExistingBlockItems()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputTextColorBlockItem = new TextColorBlockItem(Colors.Red);
var testInputBackgroundColorBlockItem = new BackgroundColorBlockItem(Colors.Blue);
var testInpuBorderColorBlockItem = new BorderColorBlockItem(Colors.Yellow);
testInputBlockItems.Add(testInputTextColorBlockItem);
testInputBlockItems.Add(testInputBackgroundColorBlockItem);
testInputBlockItems.Add(testInpuBorderColorBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 240, G = 200, B = 150 }, textColorBlockItem.Color);
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
Assert.IsNotNull(backgroundColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 0, G = 0, B = 0 }, backgroundColorBlockItem.Color);
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
}
private class ItemFilterBlockTranslatorTestUtility
{
public ItemFilterBlockTranslatorTestUtility()

View File

@@ -265,7 +265,28 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(4, block.BlockItems.Count);
var baseTypeItem = block.BlockItems.OfType<BaseTypeBlockItem>().First();
Assert.AreEqual(2, baseTypeItem.Items.Count);
}
[Test]
public void TranslateStringToItemFilterScript_OneLineDescriptionNoBlockDescriptionAddsDescriptionToScript()
{
// Arrange
var testInputScript = "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" +
Environment.NewLine +
"Show" + Environment.NewLine +
"BaseType \"Maelström Staff\"" + Environment.NewLine + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
_testUtility.MockThemeComponentListBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual("Script edited with Filtration - https://github.com/ben-wallis/Filtration", result.Description);
var firstBlock = result.ItemFilterBlocks.First();
Assert.IsNullOrEmpty(firstBlock.Description);
}
private class ItemFilterScriptTranslatorTestUtility