Various refactorings to support ItemFilterPreview
This commit is contained in:
@@ -42,12 +42,12 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentAssertions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.dll</HintPath>
|
||||
<Reference Include="FluentAssertions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentAssertions.4.2.1\lib\net45\FluentAssertions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="FluentAssertions.Core, Version=4.1.1.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.Core.dll</HintPath>
|
||||
<Reference Include="FluentAssertions.Core, Version=4.2.1.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentAssertions.4.2.1\lib\net45\FluentAssertions.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
@@ -61,6 +61,10 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="YamlDotNet, Version=3.7.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\YamlDotNet.3.7.0\lib\net35\YamlDotNet.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||
@@ -74,6 +78,7 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Services\serializationtest.cs" />
|
||||
<Compile Include="Services\TestItemBlockItemMatcher.cs" />
|
||||
<Compile Include="Services\TestItemFilterProcessor.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Filtration.ItemFilterPreview.Model;
|
||||
using Filtration.ItemFilterPreview.Services;
|
||||
using Filtration.ObjectModel;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Resources;
|
||||
using System.Runtime.Versioning;
|
||||
using Filtration.ItemFilterPreview.Model;
|
||||
using Filtration.ItemFilterPreview.Services;
|
||||
using Filtration.ItemFilterPreview.Tests.Properties;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.Translators;
|
||||
@@ -45,11 +42,11 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
||||
|
||||
//Assert
|
||||
_testUtility.MockBlockItemMatcher.Verify();
|
||||
Assert.AreEqual(testInputBlock, result[testInputItem]);
|
||||
Assert.AreEqual(testInputBlock, result.First(r => r.ItemFilterBlock == testInputBlock).ItemFilterBlock);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProcessItemsAgainstItemFilterScript_DoesNotMatch_ReturnsFalse()
|
||||
public void ProcessItemsAgainstItemFilterScript_DoesNotMatch_ResultHasNullItemFilterBlock()
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>();
|
||||
@@ -66,7 +63,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
||||
|
||||
//Assert
|
||||
_testUtility.MockBlockItemMatcher.Verify();
|
||||
Assert.AreEqual(null, result[testInputItem]);
|
||||
Assert.AreEqual(null, result.First(r => r.Item == testInputItem).ItemFilterBlock);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -96,7 +93,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
||||
var result = itemFilterProcessor.ProcessItemsAgainstItemFilterScript(script, new List<IItem> { testInputItem });
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("Wands", result.Values.First().BlockItems.OfType<ClassBlockItem>().First().Items.First());
|
||||
Assert.AreEqual("Wands", result.First().ItemFilterBlock.BlockItems.OfType<ClassBlockItem>().First().Items.First());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -228,7 +225,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
||||
var result = itemFilterProcessor.ProcessItemsAgainstItemFilterScript(script, testInputItems);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("Wands", result.Values.First().BlockItems.OfType<ClassBlockItem>().First().Items.First());
|
||||
Assert.AreEqual("Wands", result.First().ItemFilterBlock.BlockItems.OfType<ClassBlockItem>().First().Items.First());
|
||||
}
|
||||
|
||||
private class ItemFilterProcessorTestUtility
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using Filtration.ItemFilterPreview.Model;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using NUnit.Framework;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Filtration.ItemFilterPreview.Tests.Services
|
||||
{
|
||||
class serializationtest
|
||||
{
|
||||
[Test]
|
||||
public void test_serialization()
|
||||
{
|
||||
//Arrange
|
||||
var item = new Item
|
||||
{
|
||||
ItemClass = "Test Class",
|
||||
BaseType = "Test Base Type",
|
||||
DropLevel = 54,
|
||||
Height = 2,
|
||||
Width = 2,
|
||||
ItemLevel = 50,
|
||||
ItemRarity = ItemRarity.Rare,
|
||||
SocketGroups = new List<SocketGroup> {new SocketGroup(new List<Socket> {new Socket(SocketColor.Red), new Socket(SocketColor.Blue), new Socket(SocketColor.White)}, true)},
|
||||
Quality = 12
|
||||
};
|
||||
|
||||
//Act
|
||||
|
||||
var serializer = new XmlSerializer(item.GetType());
|
||||
var output = string.Empty;
|
||||
using (var textWriter = new StringWriter())
|
||||
{
|
||||
serializer.Serialize(textWriter, item);
|
||||
output = textWriter.ToString();
|
||||
}
|
||||
|
||||
var x = 2;
|
||||
//Assert
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Xceed.Wpf.AvalonDock" publicKeyToken="3e4669d2f30244f4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentAssertions" version="4.1.1" targetFramework="net461" />
|
||||
<package id="FluentAssertions" version="4.2.1" targetFramework="net461" />
|
||||
<package id="Moq" version="4.2.1510.2205" targetFramework="net46" />
|
||||
<package id="NUnit" version="3.0.1" targetFramework="net46" />
|
||||
<package id="YamlDotNet" version="3.7.0" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user