FIL-4 Refactored script parsing to retain isolated comments as a new ItemFilterBlockComment type - UI still needs reworking with new templates and such.
This commit is contained in:
@@ -109,6 +109,9 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\testscript2.txt" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
|
||||
@@ -91,6 +91,37 @@ namespace Filtration.Parser.Tests.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to #Script description
|
||||
///#Script description
|
||||
///#Script description
|
||||
///#Script description
|
||||
///
|
||||
///#Comment
|
||||
///#SomeComment
|
||||
///
|
||||
///#Blockdescription
|
||||
///Show #Flasks - Endgame - Life/Mana - Divine/Eternal - Q10+ - Normal
|
||||
/// Class "Life Flasks" "Mana Flasks"
|
||||
/// Rarity Normal
|
||||
/// DropLevel >= 60
|
||||
/// Quality >= 10
|
||||
/// SetFontSize 28
|
||||
/// SetTextColor 240 240 240 #Normal Item Highlight
|
||||
///
|
||||
///#commentymccommentface
|
||||
///
|
||||
///Show #Flasks - Endgame - Life/Mana - Divine/Eternal - Q10+ - Normal
|
||||
/// Class "Life Flasks" "Mana Flasks"
|
||||
/// Rarity Normal
|
||||
/// DropL [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
public static string testscript2 {
|
||||
get {
|
||||
return ResourceManager.GetString("testscript2", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ###BETA VERSION 1.0.0.1-8
|
||||
///#Please test and let me know via pm on reddit /u/brute_force or @Thiole in game if i am online
|
||||
|
||||
@@ -118,10 +118,13 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ThioleItemFilter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ThioleItemFilter.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="testscript" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\testscript.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="testscript2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\testscript2.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="ThioleItemFilter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ThioleItemFilter.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
</root>
|
||||
31
Filtration.Parser.Tests/Resources/testscript2.txt
Normal file
31
Filtration.Parser.Tests/Resources/testscript2.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
#Script description
|
||||
#Script description
|
||||
#Script description
|
||||
#Script description
|
||||
|
||||
#Blockdescription
|
||||
Show #Flasks - Endgame - Life/Mana - Divine/Eternal - Q10+ - Normal
|
||||
Class "Life Flasks" "Mana Flasks"
|
||||
Rarity Normal
|
||||
SetFontSize 28
|
||||
|
||||
|
||||
|
||||
# commentymccommentface
|
||||
|
||||
Show
|
||||
Class "Life Flasks" "Mana Flasks"
|
||||
Rarity Normal
|
||||
DropLevel >= 60
|
||||
|
||||
#commment
|
||||
#morecomment
|
||||
#blah
|
||||
|
||||
#anothercomment
|
||||
|
||||
#notpartofblockdescription
|
||||
#blockdescription2
|
||||
Show #TestBlock
|
||||
Class "Life Flasks" "Mana Flasks"
|
||||
Rarity Normal
|
||||
@@ -26,6 +26,19 @@ namespace Filtration.Parser.Tests.Services
|
||||
_testUtility = new ItemFilterBlockTranslatorTestUtility();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlockComment_ReturnsItemFilterBlockCommentWithSpacesNotRemoved()
|
||||
{
|
||||
//Arrange
|
||||
var testInputString = "# This is a comment\r\n# Line 2 \r\n # Test";
|
||||
|
||||
//Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterCommentBlock(testInputString);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(" This is a comment\r\n Line 2 \r\n Test", result.Comment);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_BlockGroupsEnabled_ActionBlockItemCommentIsNull()
|
||||
{
|
||||
@@ -703,21 +716,6 @@ namespace Filtration.Parser.Tests.Services
|
||||
Assert.AreEqual(2, blockItem.Value);
|
||||
Assert.AreEqual(95, blockItem.SecondValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_SectionComment_ReturnsItemFilterSectionObjectWithCorrectDescription()
|
||||
{
|
||||
// Arrange
|
||||
const string testInputSectionDescription = "Wonderful items that you definitely won't want to miss!";
|
||||
var inputString = "# Section: " + testInputSectionDescription;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, Mock.Of<IItemFilterScriptSettings>());
|
||||
|
||||
// Assert
|
||||
Assert.IsInstanceOf<ItemFilterSection>(result);
|
||||
Assert.AreEqual(testInputSectionDescription, result.Description);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject()
|
||||
@@ -1571,22 +1569,6 @@ namespace Filtration.Parser.Tests.Services
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterBlockToString_Section_ReturnsCorrectString()
|
||||
{
|
||||
// Arrange
|
||||
const string testInputSectionText = "Ermagerd it's a section!";
|
||||
var expectedResult = "# Section: " + testInputSectionText;
|
||||
|
||||
_testUtility.TestBlock = new ItemFilterSection { Description = testInputSectionText };
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterBlockToString_DisabledBlock_ReturnsCorrectString()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
@@ -9,6 +10,7 @@ using Filtration.Parser.Interface.Services;
|
||||
using Filtration.Parser.Services;
|
||||
using Filtration.Parser.Tests.Properties;
|
||||
using Filtration.Properties;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -75,6 +77,36 @@ namespace Filtration.Parser.Tests.Services
|
||||
// Not crashing out when loading a huge script means this integration test has passed!
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_Blah()
|
||||
{
|
||||
// Arrange
|
||||
var testInput = Resources.testscript2;
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator, _testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInput);
|
||||
|
||||
// Assert
|
||||
var expectedResult = Mock.Of<IItemFilterScript>(s => s.ItemFilterBlocks == new ObservableCollection<IItemFilterBlockBase>
|
||||
{
|
||||
Mock.Of<IItemFilterBlock>(c => c.Description == "Blockdescription"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == " commentymccommentface"),
|
||||
Mock.Of<IItemFilterBlock>(),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "commment\r\nmorecomment\r\nblah"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "anothercomment"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "notpartofblockdescription "),
|
||||
Mock.Of<IItemFilterBlock>(c => c.Description == "blockdescription2")
|
||||
} && s.ItemFilterBlockGroups == new ObservableCollection<ItemFilterBlockGroup> { new ItemFilterBlockGroup("Root", null, false) }
|
||||
&& s.ThemeComponents == new ThemeComponentCollection()
|
||||
&& s.ItemFilterScriptSettings == new ItemFilterScriptSettings(new ThemeComponentCollection())
|
||||
&& s.Description == "Script description\r\nScript description\r\nScript description\r\nScript description");
|
||||
|
||||
result.ShouldBeEquivalentTo(expectedResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterScriptToString_OneBlock_CallsTranslator()
|
||||
{
|
||||
@@ -221,7 +253,7 @@ namespace Filtration.Parser.Tests.Services
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
|
||||
var block = result.ItemFilterBlocks.First(l => l.GetType() != typeof(ItemFilterSection));
|
||||
var block = result.ItemFilterBlocks.OfType<ItemFilterBlock>().First(l => l.GetType() != typeof(ItemFilterSection));
|
||||
Assert.AreEqual(4, block.BlockItems.Count);
|
||||
var baseTypeItem = block.BlockItems.OfType<BaseTypeBlockItem>().First();
|
||||
Assert.AreEqual(2, baseTypeItem.Items.Count);
|
||||
@@ -244,7 +276,7 @@ namespace Filtration.Parser.Tests.Services
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Script edited with Filtration - https://github.com/ben-wallis/Filtration", result.Description);
|
||||
var firstBlock = result.ItemFilterBlocks.First();
|
||||
var firstBlock = result.ItemFilterBlocks.OfType<ItemFilterBlock>().First();
|
||||
Assert.IsNull(firstBlock.Description);
|
||||
}
|
||||
|
||||
@@ -311,9 +343,9 @@ namespace Filtration.Parser.Tests.Services
|
||||
// Assert
|
||||
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
|
||||
|
||||
var firstBlock = result.ItemFilterBlocks.First();
|
||||
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||
var thirdBlock = result.ItemFilterBlocks.Skip(2).First();
|
||||
var firstBlock = result.ItemFilterBlocks.OfType<ItemFilterBlock>().First();
|
||||
var secondBlock = result.ItemFilterBlocks.OfType<ItemFilterBlock>().Skip(1).First();
|
||||
var thirdBlock = result.ItemFilterBlocks.OfType<ItemFilterBlock>().Skip(2).First();
|
||||
|
||||
Assert.AreEqual(3, firstBlock.BlockItems.Count);
|
||||
Assert.AreEqual(5, secondBlock.BlockItems.Count);
|
||||
@@ -344,7 +376,7 @@ namespace Filtration.Parser.Tests.Services
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
|
||||
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||
var secondBlock = result.ItemFilterBlocks.OfType<ItemFilterBlock>().Skip(1).First();
|
||||
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||
}
|
||||
|
||||
@@ -379,7 +411,7 @@ namespace Filtration.Parser.Tests.Services
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
|
||||
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||
var secondBlock = result.ItemFilterBlocks.OfType<ItemFilterBlock>().Skip(1).First();
|
||||
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||
Assert.AreEqual("My Block Group", secondBlock.BlockGroup.GroupName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user