diff --git a/Filtration.ItemFilterPreview.Tests/Filtration.ItemFilterPreview.Tests.csproj b/Filtration.ItemFilterPreview.Tests/Filtration.ItemFilterPreview.Tests.csproj
index dffa068..72da2a5 100644
--- a/Filtration.ItemFilterPreview.Tests/Filtration.ItemFilterPreview.Tests.csproj
+++ b/Filtration.ItemFilterPreview.Tests/Filtration.ItemFilterPreview.Tests.csproj
@@ -42,6 +42,14 @@
4
+
+ ..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.dll
+ True
+
+
+ ..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.Core.dll
+ True
+
..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll
True
@@ -51,6 +59,8 @@
True
+
+
diff --git a/Filtration.ItemFilterPreview.Tests/Services/TestItemBlockItemMatcher.cs b/Filtration.ItemFilterPreview.Tests/Services/TestItemBlockItemMatcher.cs
index d9a3ac0..98c90fd 100644
--- a/Filtration.ItemFilterPreview.Tests/Services/TestItemBlockItemMatcher.cs
+++ b/Filtration.ItemFilterPreview.Tests/Services/TestItemBlockItemMatcher.cs
@@ -26,11 +26,104 @@ namespace Filtration.ItemFilterPreview.Tests.Services
_testUtility = new ItemBlockItemMatcherTestUtility();
}
+ [Test]
+ public void ItemBlockMatch_EmptyShowBlock_ReturnsTrue()
+ {
+ //Arrange
+ var testInputItem = Mock.Of();
+ 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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; }
}
}
}
diff --git a/Filtration.ItemFilterPreview.Tests/Services/TestItemFilterProcessor.cs b/Filtration.ItemFilterPreview.Tests/Services/TestItemFilterProcessor.cs
index 9e31fdf..2b5b482 100644
--- a/Filtration.ItemFilterPreview.Tests/Services/TestItemFilterProcessor.cs
+++ b/Filtration.ItemFilterPreview.Tests/Services/TestItemFilterProcessor.cs
@@ -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(i => i.ItemClass == "Test Class");
+ var testInputBlockItem = new ActionBlockItem(BlockAction.Show);
+ var testInputBlock = Mock.Of(b => b.Action == BlockAction.Show &&
+ b.BlockItems == new ObservableCollection {testInputBlockItem});
+ var testInputScript = Mock.Of(s => s.ItemFilterBlocks == new ObservableCollection {testInputBlock});
+
+ //Act
+ var result = _testUtility.ItemFilterProcessor.ProcessItemsAgainstItemFilterScript(testInputScript, new List { testInputItem });
+
+ //Assert
+ Assert.AreEqual(testInputBlock, result[testInputItem]);
+ }
+
+ private class ItemFilterProcessorTestUtility
+ {
+ public ItemFilterProcessorTestUtility()
+ {
+ // Mock setups
+ MockBlockItemMatcher = new Mock();
+
+ // Class under-test instantiation
+ ItemFilterProcessor = new ItemFilterProcessor(MockBlockItemMatcher.Object);
+ }
+
+ public ItemFilterProcessor ItemFilterProcessor { get; private set; }
+
+ public Mock MockBlockItemMatcher { get; }
+ }
}
}
diff --git a/Filtration.ItemFilterPreview.Tests/packages.config b/Filtration.ItemFilterPreview.Tests/packages.config
index 447fc08..b43dde7 100644
--- a/Filtration.ItemFilterPreview.Tests/packages.config
+++ b/Filtration.ItemFilterPreview.Tests/packages.config
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/Filtration.ItemFilterPreview/Filtration.ItemFilterPreview.csproj b/Filtration.ItemFilterPreview/Filtration.ItemFilterPreview.csproj
index f062c70..3ede1c3 100644
--- a/Filtration.ItemFilterPreview/Filtration.ItemFilterPreview.csproj
+++ b/Filtration.ItemFilterPreview/Filtration.ItemFilterPreview.csproj
@@ -58,7 +58,7 @@
-
+
ItemSocketsControl.xaml
diff --git a/Filtration.ItemFilterPreview/Model/Item.cs b/Filtration.ItemFilterPreview/Model/Item.cs
index 9006fe1..92df6db 100644
--- a/Filtration.ItemFilterPreview/Model/Item.cs
+++ b/Filtration.ItemFilterPreview/Model/Item.cs
@@ -8,7 +8,6 @@ namespace Filtration.ItemFilterPreview.Model
{
public interface IItem
{
- List 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 LinkedSocketGroups { get; }
+ List SocketGroups { get; set; }
}
public class Item : IItem
{
private List _socketGroups;
-
- public Item(List 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 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; }
}
}
diff --git a/Filtration.ItemFilterPreview/Services/BlockItemMatcher.cs b/Filtration.ItemFilterPreview/Services/BlockItemMatcher.cs
new file mode 100644
index 0000000..1b8916d
--- /dev/null
+++ b/Filtration.ItemFilterPreview/Services/BlockItemMatcher.cs
@@ -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 numericFilterPredicateBlockItem, int matchValue) where T : NumericFilterPredicateBlockItem
+ {
+ return numericFilterPredicateBlockItem.FilterPredicate.CompareUsing(matchValue);
+ }
+ }
+}
diff --git a/Filtration.ItemFilterPreview/Services/ItemBlockItemMatcher.cs b/Filtration.ItemFilterPreview/Services/ItemBlockItemMatcher.cs
deleted file mode 100644
index af1d8e7..0000000
--- a/Filtration.ItemFilterPreview/Services/ItemBlockItemMatcher.cs
+++ /dev/null
@@ -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 numericFilterPredicateBlockItem, int matchValue) where T : NumericFilterPredicateBlockItem
- {
- return numericFilterPredicateBlockItem.FilterPredicate.CompareUsing(matchValue);
- }
- }
-}
diff --git a/Filtration.ItemFilterPreview/Services/ItemFilterProcessor.cs b/Filtration.ItemFilterPreview/Services/ItemFilterProcessor.cs
index bd8edfd..c1e6fd2 100644
--- a/Filtration.ItemFilterPreview/Services/ItemFilterProcessor.cs
+++ b/Filtration.ItemFilterPreview/Services/ItemFilterProcessor.cs
@@ -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 ProcessItemsAgainstItemFilterScript(IItemFilterScript itemFilterScript, IEnumerable items)
{
- _itemFilterScript = itemFilterScript;
- }
+ var matchedItemBlockPairs = new Dictionary();
- 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;
+ }
}
}
diff --git a/Filtration.ObjectModel/ItemFilterBlock.cs b/Filtration.ObjectModel/ItemFilterBlock.cs
index f9e9d7a..c34f6f1 100644
--- a/Filtration.ObjectModel/ItemFilterBlock.cs
+++ b/Filtration.ObjectModel/ItemFilterBlock.cs
@@ -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 BlockItems { get; }
+ int BlockCount(Type type);
+ bool AddBlockItemAllowed(Type type);
+ bool HasBlockItemOfType();
+ bool HasBlockGroupInParentHierarchy(ItemFilterBlockGroup targetBlockGroup, ItemFilterBlockGroup startingBlockGroup);
+ }
+
+ public class ItemFilterBlock : IItemFilterBlock
{
private ItemFilterBlockGroup _blockGroup;
diff --git a/Filtration.ObjectModel/ItemFilterScript.cs b/Filtration.ObjectModel/ItemFilterScript.cs
index b03b115..c78e531 100644
--- a/Filtration.ObjectModel/ItemFilterScript.cs
+++ b/Filtration.ObjectModel/ItemFilterScript.cs
@@ -9,7 +9,7 @@ namespace Filtration.ObjectModel
{
public interface IItemFilterScript
{
- ObservableCollection ItemFilterBlocks { get; }
+ ObservableCollection ItemFilterBlocks { get; }
ObservableCollection ItemFilterBlockGroups { get; }
ThemeComponentCollection ThemeComponents { get; set; }
string FilePath { get; set; }
@@ -23,7 +23,7 @@ namespace Filtration.ObjectModel
{
public ItemFilterScript()
{
- ItemFilterBlocks = new ObservableCollection();
+ ItemFilterBlocks = new ObservableCollection();
ItemFilterBlockGroups = new ObservableCollection
{
new ItemFilterBlockGroup("Root", null)
@@ -31,7 +31,7 @@ namespace Filtration.ObjectModel
ThemeComponents = new ThemeComponentCollection { IsMasterCollection = true};
}
- public ObservableCollection ItemFilterBlocks { get; }
+ public ObservableCollection ItemFilterBlocks { get; }
public ObservableCollection 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()
? block.BlockItems.OfType().First()
diff --git a/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs b/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs
index 648e7b8..3e2419a 100644
--- a/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs
+++ b/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs
@@ -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()
{
diff --git a/Filtration.Tests/app.config b/Filtration.Tests/app.config
index 4e5d75f..b0ca7b2 100644
--- a/Filtration.Tests/app.config
+++ b/Filtration.Tests/app.config
@@ -1,11 +1,11 @@
-
+
-
-
+
+
-
+
diff --git a/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj b/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj
index df93808..fdada7a 100644
--- a/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj
+++ b/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj
@@ -58,7 +58,7 @@
..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll
- ..\packages\NLog.4.2.2\lib\net45\NLog.dll
+ ..\packages\NLog.4.2.3\lib\net45\NLog.dll
True
diff --git a/Filtration.ThemeEditor/packages.config b/Filtration.ThemeEditor/packages.config
index 9c89df4..627e334 100644
--- a/Filtration.ThemeEditor/packages.config
+++ b/Filtration.ThemeEditor/packages.config
@@ -6,5 +6,5 @@
-
+
\ No newline at end of file
diff --git a/Filtration/App.config b/Filtration/App.config
index 9bf0c0d..cf2a739 100644
--- a/Filtration/App.config
+++ b/Filtration/App.config
@@ -1,17 +1,17 @@
-
+
-
+
-
+
-
+
True
@@ -30,8 +30,8 @@
-
-
+
+
diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj
index 31dd393..b0065a1 100644
--- a/Filtration/Filtration.csproj
+++ b/Filtration/Filtration.csproj
@@ -73,7 +73,7 @@
..\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll
- ..\packages\NLog.4.2.2\lib\net45\NLog.dll
+ ..\packages\NLog.4.2.3\lib\net45\NLog.dll
True
diff --git a/Filtration/Translators/ItemFilterBlockTranslator.cs b/Filtration/Translators/ItemFilterBlockTranslator.cs
index 4a99007..f0055ed 100644
--- a/Filtration/Translators/ItemFilterBlockTranslator.cs
+++ b/Filtration/Translators/ItemFilterBlockTranslator.cs
@@ -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 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(ItemFilterBlock block)
+ private static void RemoveExistingBlockItemsOfType(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(ItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem
+ private static void AddNumericFilterPredicateItemToBlockItems(IItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem
{
var blockItem = Activator.CreateInstance();
@@ -262,7 +262,7 @@ namespace Filtration.Translators
predicate.PredicateOperand = Convert.ToInt16(result.Groups[2].Value);
}
- private static void AddStringListItemToBlockItems(ItemFilterBlock block, string inputString) where T : StringListBlockItem
+ private static void AddStringListItemToBlockItems(IItemFilterBlock block, string inputString) where T : StringListBlockItem
{
var blockItem = Activator.CreateInstance();
PopulateListFromString(blockItem.Items, inputString.Substring(inputString.IndexOf(" ", StringComparison.Ordinal) + 1).Trim());
@@ -280,7 +280,7 @@ namespace Filtration.Translators
}
}
- private void AddColorItemToBlockItems(ItemFilterBlock block, string inputString) where T : ColorBlockItem
+ private void AddColorItemToBlockItems(IItemFilterBlock block, string inputString) where T : ColorBlockItem
{
block.BlockItems.Add(GetColorBlockItemFromString(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))
{
diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs
index e17c1b3..9d403dc 100644
--- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs
+++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs
@@ -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; }
diff --git a/Filtration/ViewModels/ReplaceColorsViewModel.cs b/Filtration/ViewModels/ReplaceColorsViewModel.cs
index db89ec5..28aafef 100644
--- a/Filtration/ViewModels/ReplaceColorsViewModel.cs
+++ b/Filtration/ViewModels/ReplaceColorsViewModel.cs
@@ -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();
diff --git a/Filtration/packages.config b/Filtration/packages.config
index 7c927c0..a271df8 100644
--- a/Filtration/packages.config
+++ b/Filtration/packages.config
@@ -8,7 +8,7 @@
-
+