More work on item filter processing
This commit is contained in:
parent
89e98fc8c6
commit
1bdc8bf6fd
|
@ -42,6 +42,14 @@
|
|||
<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>
|
||||
<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>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@ -51,6 +59,8 @@
|
|||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||
|
|
|
@ -26,11 +26,104 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
_testUtility = new ItemBlockItemMatcherTestUtility();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemBlockMatch_EmptyShowBlock_ReturnsTrue()
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>();
|
||||
var testInputBlock = new ItemFilterBlock();
|
||||
|
||||
//Act
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemBlockMatch_SingleBlockItem_Matches_ReturnsTrue()
|
||||
{
|
||||
//Arrange
|
||||
var testBaseType = "Test Base Type";
|
||||
var testInputItem = Mock.Of<IItem>(i => i.BaseType == testBaseType);
|
||||
var testInputBlock = new ItemFilterBlock();
|
||||
var baseTypeBlockItem = new BaseTypeBlockItem();
|
||||
baseTypeBlockItem.Items.Add(testBaseType);
|
||||
testInputBlock.BlockItems.Add(baseTypeBlockItem);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemBlockMatch_SingleBlockItem_DoesNotMatche_ReturnsFalse()
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.BaseType == "Base Type 1");
|
||||
var testInputBlock = new ItemFilterBlock();
|
||||
var baseTypeBlockItem = new BaseTypeBlockItem();
|
||||
baseTypeBlockItem.Items.Add("Base Type 2");
|
||||
testInputBlock.BlockItems.Add(baseTypeBlockItem);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemBlockMatch_MultipleBlockItems_Matches_ReturnsTrue()
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.BaseType == "Base Type 1" && i.Height == 4 && i.Width == 2);
|
||||
var testInputBlock = new ItemFilterBlock();
|
||||
var baseTypeBlockItem = new BaseTypeBlockItem();
|
||||
baseTypeBlockItem.Items.Add("Base Type 1");
|
||||
var heightBlockItem = new HeightBlockItem(FilterPredicateOperator.Equal, 4);
|
||||
var widthBlockItem = new WidthBlockItem(FilterPredicateOperator.Equal, 2);
|
||||
|
||||
testInputBlock.BlockItems.Add(baseTypeBlockItem);
|
||||
testInputBlock.BlockItems.Add(heightBlockItem);
|
||||
testInputBlock.BlockItems.Add(widthBlockItem);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemBlockMatch_MultipleBlockItems_DoesNotMatch_ReturnsFalse()
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.BaseType == "Base Type 1" && i.Height == 4 && i.Width == 2);
|
||||
var testInputBlock = new ItemFilterBlock();
|
||||
var baseTypeBlockItem = new BaseTypeBlockItem();
|
||||
baseTypeBlockItem.Items.Add("Base Type d");
|
||||
var heightBlockItem = new HeightBlockItem(FilterPredicateOperator.Equal, 3);
|
||||
var widthBlockItem = new WidthBlockItem(FilterPredicateOperator.Equal, 2);
|
||||
|
||||
testInputBlock.BlockItems.Add(baseTypeBlockItem);
|
||||
testInputBlock.BlockItems.Add(heightBlockItem);
|
||||
testInputBlock.BlockItems.Add(widthBlockItem);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[TestCase("Test Base Type", true)]
|
||||
[TestCase("Test Bas", true)]
|
||||
[TestCase("T", true)]
|
||||
[TestCase("Base Type", false)]
|
||||
public void BaseTypeBlockItemMatch_SingleBlockItemValue_ReturnsTrue(string testInputBaseType, bool expectedResult)
|
||||
public void ItemBlockItemMatch_BaseTypeBlockItem_SingleBlockItemValue_ReturnsTrue(string testInputBaseType, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.BaseType == "Test Base Type");
|
||||
|
@ -38,7 +131,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
testInputBaseTypeBlockItem.Items.Add(testInputBaseType);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.BaseTypeBlockItemMatch(testInputBaseTypeBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBaseTypeBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -48,7 +141,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase("Test Bas", true)]
|
||||
[TestCase("T", true)]
|
||||
[TestCase("Base Type", false)]
|
||||
public void BaseTypeBlockItemMatch_MultipleBlockItemValues_ReturnsCorrectResult(string testInputBaseType, bool expectedResult)
|
||||
public void ItemBlockItemMatch_BaseTypeBlockItem_MultipleBlockItemValues_ReturnsCorrectResult(string testInputBaseType, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.BaseType == "Test Base Type");
|
||||
|
@ -58,7 +151,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
testInputBlockItem.Items.Add("Blah");
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.BaseTypeBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -68,7 +161,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase("Test It", true)]
|
||||
[TestCase("T", true)]
|
||||
[TestCase("Item Class", false)]
|
||||
public void ItemClassBlockItemMatch_SingleBlockItemValue_ReturnsCorrectResult(string testInputBlockItemItemClass, bool expectedResult)
|
||||
public void ItemBlockItemMatch_ClassBlockItem_SingleBlockItemValue_ReturnsCorrectResult(string testInputBlockItemItemClass, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.ItemClass == "Test Item Class");
|
||||
|
@ -76,7 +169,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
testInputBlockItem.Items.Add(testInputBlockItemItemClass);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.ClassBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -98,14 +191,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 50, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 51, true)]
|
||||
[TestCase(-1, 51, false)]
|
||||
public void DropLevelBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemDropLevel, bool expectedResult)
|
||||
public void ItemBlockItemMatch_DropLevelBlockItem_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemDropLevel, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.DropLevel == 50);
|
||||
var testInputBlockItem = new DropLevelBlockItem(testInputFilterPredicateOperator, testInputBlockItemDropLevel);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.DropLevelBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -127,14 +220,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 2, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||
[TestCase(-1, 3, false)]
|
||||
public void HeightBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemHeight, bool expectedResult)
|
||||
public void ItemBlockItemMatch_HeightBlockItem_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemHeight, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.Height == 2);
|
||||
var testInputBlockItem = new HeightBlockItem(testInputFilterPredicateOperator, testInputBlockItemHeight);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.HeightBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -156,14 +249,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 50, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 51, true)]
|
||||
[TestCase(-1, 51, false)]
|
||||
public void ItemLevelBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemItemLevel, bool expectedResult)
|
||||
public void ItemBlockItemMatch_ItemLevelBlockItem_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemItemLevel, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.ItemLevel == 50);
|
||||
var testInputBlockItem = new ItemLevelBlockItem(testInputFilterPredicateOperator, testInputBlockItemItemLevel);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.ItemLevelBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -185,14 +278,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 4, true)]
|
||||
[TestCase(-1, 3, false)]
|
||||
public void LinkedSocketsBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemLinkedSockets, bool expectedResult)
|
||||
public void ItemBlockItemMatch_LinkedSocketsBlockItem_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemLinkedSockets, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.LinkedSockets == 3);
|
||||
var testInputBlockItem = new LinkedSocketsBlockItem(testInputFilterPredicateOperator, testInputBlockItemLinkedSockets);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.LinkedSocketsBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -214,14 +307,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 12, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 13, true)]
|
||||
[TestCase(-1, 13, false)]
|
||||
public void QualityBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemQuality, bool expectedResult)
|
||||
public void ItemBlockItemMatch_QualityBlockItem_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemQuality, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.Quality == 12);
|
||||
var testInputBlockItem = new QualityBlockItem(testInputFilterPredicateOperator, testInputBlockItemQuality);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.QualityBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -243,14 +336,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, ItemRarity.Magic, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, ItemRarity.Rare, true)]
|
||||
[TestCase(-1, 13, false)]
|
||||
public void RarityBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemRarity, bool expectedResult)
|
||||
public void ItemBlockItemMatch_RarityBlockItem_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemRarity, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.ItemRarity == ItemRarity.Magic);
|
||||
var testInputBlockItem = new RarityBlockItem(testInputFilterPredicateOperator, testInputBlockItemRarity);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.RarityBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -272,14 +365,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 4, true)]
|
||||
[TestCase(-1, 3, false)]
|
||||
public void SocketsBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemSockets, bool expectedResult)
|
||||
public void ItemBlockItemMatch_SocketsBlockItem_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemSockets, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.Sockets == 3);
|
||||
var testInputBlockItem = new SocketsBlockItem(testInputFilterPredicateOperator, testInputBlockItemSockets);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.SocketsBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
|
@ -301,21 +394,21 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 2, true)]
|
||||
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||
[TestCase(-1, 3, false)]
|
||||
public void WidthBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemWidth, bool expectedResult)
|
||||
public void ItemBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemWidth, bool expectedResult)
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.Width == 2);
|
||||
var testInputBlockItem = new WidthBlockItem(testInputFilterPredicateOperator, testInputBlockItemWidth);
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.WidthBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SocketGroupBlockItemMatch_SingleItemSocketGroup_SingleBlockItemSocketGroup_Match_ReturnsCorrectResult()
|
||||
public void ItemBlockItemMatch_SocketGroupBlockItem_SingleItemSocketGroup_SingleBlockItemSocketGroup_Match_ReturnsCorrectResult()
|
||||
{
|
||||
//Arrange
|
||||
var testInputBlockItem = new SocketGroupBlockItem();
|
||||
|
@ -332,14 +425,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
});
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SocketGroupBlockItemMatch_SingleItemSocketGroup_SingleBlockItemSocketGroup_NoMatch_ReturnsCorrectResult()
|
||||
public void ItemBlockItemMatch_SocketGroupBlockItem_SingleItemSocketGroup_SingleBlockItemSocketGroup_NoMatch_ReturnsCorrectResult()
|
||||
{
|
||||
//Arrange
|
||||
var testInputBlockItem = new SocketGroupBlockItem();
|
||||
|
@ -355,14 +448,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
});
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SocketGroupBlockItemMatch_MultipleItemSocketGroup_SingleBlockItemSocketGroup_NoMatch_ReturnsCorrectResult()
|
||||
public void ItemBlockItemMatch_SocketGroupBlockItem_MultipleItemSocketGroup_SingleBlockItemSocketGroup_NoMatch_ReturnsCorrectResult()
|
||||
{
|
||||
//Arrange
|
||||
var testInputBlockItem = new SocketGroupBlockItem();
|
||||
|
@ -384,14 +477,14 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
});
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SocketGroupBlockItemMatch_MultipleItemSocketGroup_SingleBlockItemSocketGroup_Match_ReturnsCorrectResult()
|
||||
public void ItemBlockItemMatch_SocketGroupBlockItem_MultipleItemSocketGroup_SingleBlockItemSocketGroup_Match_ReturnsCorrectResult()
|
||||
{
|
||||
//Arrange
|
||||
var testInputBlockItem = new SocketGroupBlockItem();
|
||||
|
@ -413,13 +506,12 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
});
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBlockItem, testInputItem);
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
|
||||
private class ItemBlockItemMatcherTestUtility
|
||||
{
|
||||
public ItemBlockItemMatcherTestUtility()
|
||||
|
@ -427,10 +519,10 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
// Mock setups
|
||||
|
||||
// Class under-test instantiation
|
||||
ItemBlockItemMatcher = new ItemBlockItemMatcher();
|
||||
BlockItemMatcher = new BlockItemMatcher();
|
||||
}
|
||||
|
||||
public ItemBlockItemMatcher ItemBlockItemMatcher { get; private set; }
|
||||
public BlockItemMatcher BlockItemMatcher { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,57 @@
|
|||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Filtration.ItemFilterPreview.Model;
|
||||
using Filtration.ItemFilterPreview.Services;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.ItemFilterPreview.Tests.Services
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestItemFilterProcessor
|
||||
{
|
||||
private ItemFilterProcessorTestUtility _testUtility;
|
||||
|
||||
[SetUp]
|
||||
public void ItemFilterProcessorTestSetUp()
|
||||
{
|
||||
_testUtility = new ItemFilterProcessorTestUtility();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProcessItemsAgainstItemFilterScript_Matches_ReturnsTrue()
|
||||
{
|
||||
//Arrange
|
||||
var testInputItem = Mock.Of<IItem>(i => i.ItemClass == "Test Class");
|
||||
var testInputBlockItem = new ActionBlockItem(BlockAction.Show);
|
||||
var testInputBlock = Mock.Of<IItemFilterBlock>(b => b.Action == BlockAction.Show &&
|
||||
b.BlockItems == new ObservableCollection<IItemFilterBlockItem> {testInputBlockItem});
|
||||
var testInputScript = Mock.Of<IItemFilterScript>(s => s.ItemFilterBlocks == new ObservableCollection<IItemFilterBlock> {testInputBlock});
|
||||
|
||||
//Act
|
||||
var result = _testUtility.ItemFilterProcessor.ProcessItemsAgainstItemFilterScript(testInputScript, new List<IItem> { testInputItem });
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(testInputBlock, result[testInputItem]);
|
||||
}
|
||||
|
||||
private class ItemFilterProcessorTestUtility
|
||||
{
|
||||
public ItemFilterProcessorTestUtility()
|
||||
{
|
||||
// Mock setups
|
||||
MockBlockItemMatcher = new Mock<IBlockItemMatcher>();
|
||||
|
||||
// Class under-test instantiation
|
||||
ItemFilterProcessor = new ItemFilterProcessor(MockBlockItemMatcher.Object);
|
||||
}
|
||||
|
||||
public ItemFilterProcessor ItemFilterProcessor { get; private set; }
|
||||
|
||||
public Mock<IBlockItemMatcher> MockBlockItemMatcher { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentAssertions" version="4.1.1" targetFramework="net461" />
|
||||
<package id="Moq" version="4.2.1510.2205" targetFramework="net46" />
|
||||
<package id="NUnit" version="3.0.1" targetFramework="net46" />
|
||||
</packages>
|
|
@ -58,7 +58,7 @@
|
|||
</ApplicationDefinition>
|
||||
<Compile Include="Model\Item.cs" />
|
||||
<Compile Include="Model\ItemCollection.cs" />
|
||||
<Compile Include="Services\ItemBlockItemMatcher.cs" />
|
||||
<Compile Include="Services\BlockItemMatcher.cs" />
|
||||
<Compile Include="Services\ItemFilterProcessor.cs" />
|
||||
<Compile Include="UserControls\ItemSocketsControl.xaml.cs">
|
||||
<DependentUpon>ItemSocketsControl.xaml</DependentUpon>
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace Filtration.ItemFilterPreview.Model
|
|||
{
|
||||
public interface IItem
|
||||
{
|
||||
List<SocketGroup> SocketGroups { get; set; }
|
||||
string ItemClass { get; set; }
|
||||
string BaseType { get; set; }
|
||||
int DropLevel { get; set; }
|
||||
|
@ -20,16 +19,23 @@ namespace Filtration.ItemFilterPreview.Model
|
|||
int Sockets { get; }
|
||||
int LinkedSockets { get; }
|
||||
IEnumerable<SocketGroup> LinkedSocketGroups { get; }
|
||||
List<SocketGroup> SocketGroups { get; set; }
|
||||
}
|
||||
|
||||
public class Item : IItem
|
||||
{
|
||||
private List<SocketGroup> _socketGroups;
|
||||
|
||||
public Item(List<SocketGroup> socketGroups)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string ItemClass { get; set; }
|
||||
public string BaseType { get; set; }
|
||||
public int DropLevel { get; set; }
|
||||
public int ItemLevel { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Quality { get; set; }
|
||||
public ItemRarity ItemRarity { get; set; }
|
||||
public int Sockets { get; private set; }
|
||||
public int LinkedSockets { get; private set; }
|
||||
|
||||
public IEnumerable<SocketGroup> LinkedSocketGroups
|
||||
{
|
||||
|
@ -66,16 +72,5 @@ namespace Filtration.ItemFilterPreview.Model
|
|||
LinkedSockets = value.Where(s => s.Linked).Max(s => s.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public string ItemClass { get; set; }
|
||||
public string BaseType { get; set; }
|
||||
public int DropLevel { get; set; }
|
||||
public int ItemLevel { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Quality { get; set; }
|
||||
public ItemRarity ItemRarity { get; set; }
|
||||
public int Sockets { get; private set; }
|
||||
public int LinkedSockets { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
using System.Linq;
|
||||
using Filtration.ItemFilterPreview.Model;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
|
||||
namespace Filtration.ItemFilterPreview.Services
|
||||
{
|
||||
internal interface IBlockItemMatcher
|
||||
{
|
||||
bool ItemBlockMatch(IItemFilterBlock block, IItem item);
|
||||
bool ItemBlockItemMatch(IItemFilterBlockItem blockItem, IItem item);
|
||||
}
|
||||
|
||||
internal class BlockItemMatcher : IBlockItemMatcher
|
||||
{
|
||||
public bool ItemBlockMatch(IItemFilterBlock block, IItem item)
|
||||
{
|
||||
|
||||
return block.BlockItems
|
||||
.Where(blockItem => !(blockItem is IAudioVisualBlockItem) && !(blockItem is ActionBlockItem))
|
||||
.All(blockItem => ItemBlockItemMatch(blockItem, item));
|
||||
}
|
||||
|
||||
public bool ItemBlockItemMatch(IItemFilterBlockItem blockItem, IItem item)
|
||||
{
|
||||
var blockItemType = blockItem.GetType();
|
||||
|
||||
if (blockItemType == typeof (BaseTypeBlockItem))
|
||||
return BaseTypeBlockItemMatch((BaseTypeBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof (ClassBlockItem))
|
||||
return ClassBlockItemMatch((ClassBlockItem) blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(DropLevelBlockItem))
|
||||
return DropLevelBlockItemMatch((DropLevelBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(HeightBlockItem))
|
||||
return HeightBlockItemMatch((HeightBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(ItemLevelBlockItem))
|
||||
return ItemLevelBlockItemMatch((ItemLevelBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(LinkedSocketsBlockItem))
|
||||
return LinkedSocketsBlockItemMatch((LinkedSocketsBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(QualityBlockItem))
|
||||
return QualityBlockItemMatch((QualityBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(RarityBlockItem))
|
||||
return RarityBlockItemMatch((RarityBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(SocketsBlockItem))
|
||||
return SocketsBlockItemMatch((SocketsBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(WidthBlockItem))
|
||||
return WidthBlockItemMatch((WidthBlockItem)blockItem, item);
|
||||
|
||||
if (blockItemType == typeof(SocketGroupBlockItem))
|
||||
return SocketGroupBlockItemMatch((SocketGroupBlockItem)blockItem, item);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool BaseTypeBlockItemMatch(BaseTypeBlockItem baseTypeBlockItem, IItem item)
|
||||
{
|
||||
return baseTypeBlockItem.Items.Any(b => item.BaseType.StartsWith(b));
|
||||
}
|
||||
|
||||
private static bool ClassBlockItemMatch(ClassBlockItem classBlockItem, IItem item)
|
||||
{
|
||||
return classBlockItem.Items.Any(c => item.ItemClass.StartsWith(c));
|
||||
}
|
||||
|
||||
private static bool DropLevelBlockItemMatch(DropLevelBlockItem dropLevelBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(dropLevelBlockItem, item.DropLevel);
|
||||
}
|
||||
|
||||
private static bool HeightBlockItemMatch(HeightBlockItem heightBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(heightBlockItem, item.Height);
|
||||
}
|
||||
|
||||
private static bool ItemLevelBlockItemMatch(ItemLevelBlockItem itemLevelBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(itemLevelBlockItem, item.ItemLevel);
|
||||
}
|
||||
|
||||
private static bool LinkedSocketsBlockItemMatch(LinkedSocketsBlockItem linkedSocketsBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(linkedSocketsBlockItem, item.LinkedSockets);
|
||||
}
|
||||
|
||||
private static bool QualityBlockItemMatch(QualityBlockItem qualityBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(qualityBlockItem, item.Quality);
|
||||
}
|
||||
|
||||
private static bool RarityBlockItemMatch(RarityBlockItem qualityBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(qualityBlockItem, (int)item.ItemRarity);
|
||||
}
|
||||
|
||||
private static bool SocketsBlockItemMatch(SocketsBlockItem socketsBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(socketsBlockItem, item.Sockets);
|
||||
}
|
||||
|
||||
private static bool WidthBlockItemMatch(WidthBlockItem widthBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(widthBlockItem, item.Width);
|
||||
}
|
||||
|
||||
private static bool SocketGroupBlockItemMatch(SocketGroupBlockItem socketGroupBlockItem, IItem item)
|
||||
{
|
||||
|
||||
foreach (var blockItemSocketGroup in socketGroupBlockItem.SocketGroups) // for each group of sockets in the block item
|
||||
{
|
||||
foreach (var itemLinkedSocketGroup in item.LinkedSocketGroups) // for each linked socket group in the item
|
||||
{
|
||||
if (SocketGroupHasRequiredSocketColors(itemLinkedSocketGroup, blockItemSocketGroup))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool SocketGroupHasRequiredSocketColors(SocketGroup itemLinkedSocketGroup, SocketGroup blockItemSocketGroup)
|
||||
{
|
||||
|
||||
var blockSocketGroupColorCounts = blockItemSocketGroup.GroupBy(i => i.Color, (key, values) => new { SocketColor = key, Count = values.Count() }).ToList();
|
||||
var itemSocketGroupColorCounts = itemLinkedSocketGroup.GroupBy(i => i.Color, (key, values) => new {SocketColor = key, Count = values.Count()}).ToList();
|
||||
|
||||
foreach (var blockItemSocketColorCount in blockSocketGroupColorCounts)
|
||||
{
|
||||
var match = itemSocketGroupColorCounts.FirstOrDefault(i => i.SocketColor == blockItemSocketColorCount.SocketColor && i.Count >= blockItemSocketColorCount.Count);
|
||||
if (match == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool NumericFilterPredicateBlockItemMatch<T>(T numericFilterPredicateBlockItem, int matchValue) where T : NumericFilterPredicateBlockItem
|
||||
{
|
||||
return numericFilterPredicateBlockItem.FilterPredicate.CompareUsing(matchValue);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Filtration.ItemFilterPreview.Model;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
|
||||
namespace Filtration.ItemFilterPreview.Services
|
||||
{
|
||||
internal interface IItemBlockItemMatcher
|
||||
{
|
||||
bool BaseTypeBlockItemMatch(BaseTypeBlockItem baseTypeBlockItem, IItem item);
|
||||
bool ClassBlockItemMatch(ClassBlockItem classBlockItem, IItem item);
|
||||
bool DropLevelBlockItemMatch(DropLevelBlockItem dropLevelBlockItem, IItem item);
|
||||
}
|
||||
|
||||
internal class ItemBlockItemMatcher : IItemBlockItemMatcher
|
||||
{
|
||||
public bool BaseTypeBlockItemMatch(BaseTypeBlockItem baseTypeBlockItem, IItem item)
|
||||
{
|
||||
return baseTypeBlockItem.Items.Any(b => item.BaseType.StartsWith(b));
|
||||
}
|
||||
|
||||
public bool ClassBlockItemMatch(ClassBlockItem classBlockItem, IItem item)
|
||||
{
|
||||
return classBlockItem.Items.Any(c => item.ItemClass.StartsWith(c));
|
||||
}
|
||||
|
||||
public bool DropLevelBlockItemMatch(DropLevelBlockItem dropLevelBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(dropLevelBlockItem, item.DropLevel);
|
||||
}
|
||||
|
||||
public bool HeightBlockItemMatch(HeightBlockItem heightBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(heightBlockItem, item.Height);
|
||||
}
|
||||
|
||||
public bool ItemLevelBlockItemMatch(ItemLevelBlockItem itemLevelBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(itemLevelBlockItem, item.ItemLevel);
|
||||
}
|
||||
|
||||
public bool LinkedSocketsBlockItemMatch(LinkedSocketsBlockItem linkedSocketsBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(linkedSocketsBlockItem, item.LinkedSockets);
|
||||
}
|
||||
|
||||
public bool QualityBlockItemMatch(QualityBlockItem qualityBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(qualityBlockItem, item.Quality);
|
||||
}
|
||||
|
||||
public bool RarityBlockItemMatch(RarityBlockItem qualityBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(qualityBlockItem, (int)item.ItemRarity);
|
||||
}
|
||||
|
||||
public bool SocketsBlockItemMatch(SocketsBlockItem socketsBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(socketsBlockItem, item.Sockets);
|
||||
}
|
||||
|
||||
public bool WidthBlockItemMatch(WidthBlockItem widthBlockItem, IItem item)
|
||||
{
|
||||
return NumericFilterPredicateBlockItemMatch(widthBlockItem, item.Width);
|
||||
}
|
||||
|
||||
public bool SocketGroupBlockItemMatch(SocketGroupBlockItem socketGroupBlockItem, IItem item)
|
||||
{
|
||||
|
||||
foreach (var blockItemSocketGroup in socketGroupBlockItem.SocketGroups) // for each group of sockets in the block item
|
||||
{
|
||||
foreach (var itemLinkedSocketGroup in item.LinkedSocketGroups) // for each linked socket group in the item
|
||||
{
|
||||
if (SocketGroupHasRequiredSocketColors(itemLinkedSocketGroup, blockItemSocketGroup))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool SocketGroupHasRequiredSocketColors(SocketGroup itemLinkedSocketGroup, SocketGroup blockItemSocketGroup)
|
||||
{
|
||||
|
||||
var blockSocketGroupColorCounts = blockItemSocketGroup.GroupBy(i => i.Color, (key, values) => new { SocketColor = key, Count = values.Count() }).ToList();
|
||||
var itemSocketGroupColorCounts = itemLinkedSocketGroup.GroupBy(i => i.Color, (key, values) => new {SocketColor = key, Count = values.Count()}).ToList();
|
||||
|
||||
foreach (var blockItemSocketColorCount in blockSocketGroupColorCounts)
|
||||
{
|
||||
var match = itemSocketGroupColorCounts.FirstOrDefault(i => i.SocketColor == blockItemSocketColorCount.SocketColor && i.Count >= blockItemSocketColorCount.Count);
|
||||
if (match == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool NumericFilterPredicateBlockItemMatch<T>(T numericFilterPredicateBlockItem, int matchValue) where T : NumericFilterPredicateBlockItem
|
||||
{
|
||||
return numericFilterPredicateBlockItem.FilterPredicate.CompareUsing(matchValue);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +1,38 @@
|
|||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Filtration.ItemFilterPreview.Model;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ItemFilterPreview.Services
|
||||
{
|
||||
public class ItemFilterProcessor
|
||||
internal class ItemFilterProcessor
|
||||
{
|
||||
private IItemFilterScript _itemFilterScript;
|
||||
private readonly IBlockItemMatcher _blockItemMatcher;
|
||||
|
||||
public ItemFilterProcessor()
|
||||
internal ItemFilterProcessor(IBlockItemMatcher blockItemMatcher)
|
||||
{
|
||||
|
||||
_blockItemMatcher = blockItemMatcher;
|
||||
}
|
||||
|
||||
public void LoadItemFilterScript(IItemFilterScript itemFilterScript)
|
||||
public IReadOnlyDictionary<IItem, IItemFilterBlock> ProcessItemsAgainstItemFilterScript(IItemFilterScript itemFilterScript, IEnumerable<IItem> items)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
}
|
||||
var matchedItemBlockPairs = new Dictionary<IItem, IItemFilterBlock>();
|
||||
|
||||
public void ItemIsVisible(IItem item)
|
||||
{
|
||||
foreach (var block in _itemFilterScript.ItemFilterBlocks)
|
||||
var sw = Stopwatch.StartNew();
|
||||
foreach (var item in items)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
sw.Restart();
|
||||
|
||||
|
||||
var matchedBlock = itemFilterScript.ItemFilterBlocks.FirstOrDefault(block => _blockItemMatcher.ItemBlockMatch(block, item));
|
||||
matchedItemBlockPairs.Add(item, matchedBlock);
|
||||
|
||||
Debug.WriteLine("Processed Item in {0}ms", sw.ElapsedMilliseconds);
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
return matchedItemBlockPairs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,20 @@ using Filtration.ObjectModel.Enums;
|
|||
|
||||
namespace Filtration.ObjectModel
|
||||
{
|
||||
public class ItemFilterBlock
|
||||
public interface IItemFilterBlock
|
||||
{
|
||||
bool Enabled { get; set; }
|
||||
string Description { get; set; }
|
||||
ItemFilterBlockGroup BlockGroup { get; set; }
|
||||
BlockAction Action { get; set; }
|
||||
ObservableCollection<IItemFilterBlockItem> BlockItems { get; }
|
||||
int BlockCount(Type type);
|
||||
bool AddBlockItemAllowed(Type type);
|
||||
bool HasBlockItemOfType<T>();
|
||||
bool HasBlockGroupInParentHierarchy(ItemFilterBlockGroup targetBlockGroup, ItemFilterBlockGroup startingBlockGroup);
|
||||
}
|
||||
|
||||
public class ItemFilterBlock : IItemFilterBlock
|
||||
{
|
||||
private ItemFilterBlockGroup _blockGroup;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Filtration.ObjectModel
|
|||
{
|
||||
public interface IItemFilterScript
|
||||
{
|
||||
ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; }
|
||||
ObservableCollection<IItemFilterBlock> ItemFilterBlocks { get; }
|
||||
ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; }
|
||||
ThemeComponentCollection ThemeComponents { get; set; }
|
||||
string FilePath { get; set; }
|
||||
|
@ -23,7 +23,7 @@ namespace Filtration.ObjectModel
|
|||
{
|
||||
public ItemFilterScript()
|
||||
{
|
||||
ItemFilterBlocks = new ObservableCollection<ItemFilterBlock>();
|
||||
ItemFilterBlocks = new ObservableCollection<IItemFilterBlock>();
|
||||
ItemFilterBlockGroups = new ObservableCollection<ItemFilterBlockGroup>
|
||||
{
|
||||
new ItemFilterBlockGroup("Root", null)
|
||||
|
@ -31,7 +31,7 @@ namespace Filtration.ObjectModel
|
|||
ThemeComponents = new ThemeComponentCollection { IsMasterCollection = true};
|
||||
}
|
||||
|
||||
public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; }
|
||||
public ObservableCollection<IItemFilterBlock> ItemFilterBlocks { get; }
|
||||
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; }
|
||||
|
||||
public ThemeComponentCollection ThemeComponents { get; set; }
|
||||
|
@ -76,7 +76,7 @@ namespace Filtration.ObjectModel
|
|||
}
|
||||
}
|
||||
|
||||
private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, ItemFilterBlock block)
|
||||
private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, IItemFilterBlock block)
|
||||
{
|
||||
var textColorItem = block.HasBlockItemOfType<TextColorBlockItem>()
|
||||
? block.BlockItems.OfType<TextColorBlockItem>().First()
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace Filtration.Tests.Translators
|
|||
Assert.AreEqual(expectedDescription, script.Description);
|
||||
}
|
||||
|
||||
[Ignore("Integration Test")]
|
||||
[Ignore("Integration Test / need to fix file reading for NUnit 3.x")]
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_ThioleItemFilterTest()
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<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"/>
|
||||
<assemblyIdentity name="Xceed.Wpf.AvalonDock" publicKeyToken="3e4669d2f30244f4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup></configuration>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.2.2\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.2.3\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
|
||||
<package id="Extended.Wpf.Toolkit" version="2.5" targetFramework="net451" />
|
||||
<package id="MvvmLightLibs" version="5.2.0.0" targetFramework="net451" />
|
||||
<package id="NLog" version="4.2.2" targetFramework="net451" />
|
||||
<package id="NLog" version="4.2.3" targetFramework="net461" />
|
||||
</packages>
|
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="Filtration.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
|
||||
<section name="Filtration.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<userSettings>
|
||||
<Filtration.Properties.Settings>
|
||||
<setting name="DefaultFilterDirectory" serializeAs="String">
|
||||
<value/>
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="ExtraLineBetweenBlocks" serializeAs="String">
|
||||
<value>True</value>
|
||||
|
@ -30,8 +30,8 @@
|
|||
<runtime>
|
||||
<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"/>
|
||||
<assemblyIdentity name="Xceed.Wpf.AvalonDock" publicKeyToken="3e4669d2f30244f4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<HintPath>..\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.2.2\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.2.3\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
|
|
|
@ -17,9 +17,9 @@ namespace Filtration.Translators
|
|||
{
|
||||
internal interface IItemFilterBlockTranslator
|
||||
{
|
||||
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
|
||||
IItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
|
||||
ThemeComponentCollection masterComponentCollection);
|
||||
string TranslateItemFilterBlockToString(ItemFilterBlock block);
|
||||
string TranslateItemFilterBlockToString(IItemFilterBlock block);
|
||||
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace Filtration.Translators
|
|||
|
||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||
// and reading ItemFilterScripts from a file.
|
||||
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString, ThemeComponentCollection masterComponentCollection)
|
||||
public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, ThemeComponentCollection masterComponentCollection)
|
||||
{
|
||||
_masterComponentCollection = masterComponentCollection;
|
||||
var block = new ItemFilterBlock();
|
||||
|
@ -234,7 +234,7 @@ namespace Filtration.Translators
|
|||
return block;
|
||||
}
|
||||
|
||||
private static void RemoveExistingBlockItemsOfType<T>(ItemFilterBlock block)
|
||||
private static void RemoveExistingBlockItemsOfType<T>(IItemFilterBlock block)
|
||||
{
|
||||
var existingBlockItemCount = block.BlockItems.Count(b => b.GetType() == typeof(T));
|
||||
if (existingBlockItemCount > 0)
|
||||
|
@ -244,7 +244,7 @@ namespace Filtration.Translators
|
|||
}
|
||||
}
|
||||
|
||||
private static void AddNumericFilterPredicateItemToBlockItems<T>(ItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem
|
||||
private static void AddNumericFilterPredicateItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem
|
||||
{
|
||||
var blockItem = Activator.CreateInstance<T>();
|
||||
|
||||
|
@ -262,7 +262,7 @@ namespace Filtration.Translators
|
|||
predicate.PredicateOperand = Convert.ToInt16(result.Groups[2].Value);
|
||||
}
|
||||
|
||||
private static void AddStringListItemToBlockItems<T>(ItemFilterBlock block, string inputString) where T : StringListBlockItem
|
||||
private static void AddStringListItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : StringListBlockItem
|
||||
{
|
||||
var blockItem = Activator.CreateInstance<T>();
|
||||
PopulateListFromString(blockItem.Items, inputString.Substring(inputString.IndexOf(" ", StringComparison.Ordinal) + 1).Trim());
|
||||
|
@ -280,7 +280,7 @@ namespace Filtration.Translators
|
|||
}
|
||||
}
|
||||
|
||||
private void AddColorItemToBlockItems<T>(ItemFilterBlock block, string inputString) where T : ColorBlockItem
|
||||
private void AddColorItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : ColorBlockItem
|
||||
{
|
||||
block.BlockItems.Add(GetColorBlockItemFromString<T>(inputString));
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ namespace Filtration.Translators
|
|||
}
|
||||
}
|
||||
|
||||
private void AddBlockGroupToBlock(ItemFilterBlock block, string inputString)
|
||||
private void AddBlockGroupToBlock(IItemFilterBlock block, string inputString)
|
||||
{
|
||||
var blockGroupStart = inputString.IndexOf("#", StringComparison.Ordinal);
|
||||
if (blockGroupStart <= 0) return;
|
||||
|
@ -407,7 +407,7 @@ namespace Filtration.Translators
|
|||
|
||||
// This method converts an ItemFilterBlock object into a string. This is used for copying a ItemFilterBlock
|
||||
// to the clipboard, and when saving a ItemFilterScript.
|
||||
public string TranslateItemFilterBlockToString(ItemFilterBlock block)
|
||||
public string TranslateItemFilterBlockToString(IItemFilterBlock block)
|
||||
{
|
||||
if (block.GetType() == typeof (ItemFilterSection))
|
||||
{
|
||||
|
|
|
@ -17,10 +17,10 @@ namespace Filtration.ViewModels
|
|||
{
|
||||
internal interface IItemFilterBlockViewModel
|
||||
{
|
||||
void Initialise(ItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel);
|
||||
void Initialise(IItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel);
|
||||
bool IsDirty { get; set; }
|
||||
bool IsExpanded { get; set; }
|
||||
ItemFilterBlock Block { get; }
|
||||
IItemFilterBlock Block { get; }
|
||||
bool BlockEnabled { get; set; }
|
||||
void RefreshBlockPreview();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace Filtration.ViewModels
|
|||
PlaySoundCommand = new RelayCommand(OnPlaySoundCommand, () => HasSound);
|
||||
}
|
||||
|
||||
public void Initialise(ItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel)
|
||||
public void Initialise(IItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel)
|
||||
{
|
||||
if (itemFilterBlock == null || parentScriptViewModel == null)
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ namespace Filtration.ViewModels
|
|||
public RelayCommand PlaySoundCommand { get; private set; }
|
||||
public RelayCommand SwitchBlockItemsViewCommand { get; private set; }
|
||||
|
||||
public ItemFilterBlock Block { get; private set; }
|
||||
public IItemFilterBlock Block { get; private set; }
|
||||
|
||||
public bool IsDirty { get; set; }
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Filtration.ViewModels
|
|||
{
|
||||
internal interface IReplaceColorsViewModel
|
||||
{
|
||||
void Initialise(ItemFilterScript itemFilterScript, ItemFilterBlock initialiseFromBlock);
|
||||
void Initialise(ItemFilterScript itemFilterScript, IItemFilterBlock initialiseFromBlock);
|
||||
void Initialise(ItemFilterScript itemFilterScript);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace Filtration.ViewModels
|
|||
|
||||
public RelayCommand ReplaceColorsCommand { get; private set; }
|
||||
|
||||
public void Initialise(ItemFilterScript itemFilterScript, ItemFilterBlock initialiseFromBlock)
|
||||
public void Initialise(ItemFilterScript itemFilterScript, IItemFilterBlock initialiseFromBlock)
|
||||
{
|
||||
_replaceColorsParameterSet = new ReplaceColorsParameterSet();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<package id="Fluent.Ribbon" version="3.6.1.236" targetFramework="net451" />
|
||||
<package id="MahApps.Metro" version="1.1.2.0" targetFramework="net451" />
|
||||
<package id="MvvmLightLibs" version="5.2.0.0" targetFramework="net451" />
|
||||
<package id="NLog" version="4.2.2" targetFramework="net451" />
|
||||
<package id="NLog" version="4.2.3" targetFramework="net461" />
|
||||
<package id="NLog.Config" version="4.2.2" targetFramework="net451" />
|
||||
<package id="NLog.Schema" version="4.2.1" targetFramework="net451" />
|
||||
<package id="WpfAnimatedGif" version="1.4.13" targetFramework="net451" />
|
||||
|
|
Loading…
Reference in New Issue