Moved Object Model to separate project
This commit is contained in:
@@ -46,9 +46,6 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\TestItemFilterBlock.cs" />
|
||||
<Compile Include="Models\TestItemFilterBlockGroup.cs" />
|
||||
<Compile Include="Models\TestItemFilterScript.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Repositories\TestItemFilterScriptRepository.cs" />
|
||||
<Compile Include="Services\TestItemFilterPersistenceService.cs" />
|
||||
@@ -61,9 +58,14 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="ViewModels\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
|
||||
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
|
||||
<Name>Filtration.ObjectModel</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Filtration\Filtration.csproj">
|
||||
<Project>{55e0a34c-e039-43d7-a024-a4045401cdda}</Project>
|
||||
<Name>Filtration</Name>
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
using Filtration.Models;
|
||||
using Filtration.Models.BlockItemTypes;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.Tests.Models
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestItemFilterBlock
|
||||
{
|
||||
[Test]
|
||||
public void ItemFilterBlock_BlockCount_ReturnsCorrectNumber()
|
||||
{
|
||||
// Arrange
|
||||
var block = new ItemFilterBlock();
|
||||
block.BlockItems.Add(new ItemLevelBlockItem());
|
||||
block.BlockItems.Add(new ItemLevelBlockItem());
|
||||
block.BlockItems.Add(new ItemLevelBlockItem());
|
||||
block.BlockItems.Add(new ItemLevelBlockItem());
|
||||
|
||||
// Act
|
||||
var count = block.BlockCount(typeof (ItemLevelBlockItem));
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(4, count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemFilterBlock_AddBlockItemAllowed_LessThanMaximum_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var block = new ItemFilterBlock();
|
||||
block.BlockItems.Add(new ItemLevelBlockItem());
|
||||
|
||||
// Act
|
||||
bool result = block.AddBlockItemAllowed(typeof (ItemLevelBlockItem));
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemFilterBlock_AddBlockItemAllowed_MoreThanMaximum_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var block = new ItemFilterBlock();
|
||||
block.BlockItems.Add(new SoundBlockItem());
|
||||
|
||||
// Act
|
||||
bool result = block.AddBlockItemAllowed(typeof (SoundBlockItem));
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HasParentInBlockGroupHierarchy_ReturnsCorrectResult()
|
||||
{
|
||||
// Arrange
|
||||
var testInputRootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
|
||||
var testInputSubBlockGroup = new ItemFilterBlockGroup("Sub Block Group", testInputRootBlockGroup);
|
||||
var testInputSubSubBlockGroup = new ItemFilterBlockGroup("Sub Sub Block Group", testInputSubBlockGroup);
|
||||
|
||||
var block = new ItemFilterBlock {BlockGroup = testInputSubSubBlockGroup};
|
||||
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(true, block.HasBlockGroupInParentHierarchy(testInputRootBlockGroup, block.BlockGroup));
|
||||
Assert.AreEqual(true, block.HasBlockGroupInParentHierarchy(testInputSubBlockGroup, block.BlockGroup));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.Models;
|
||||
using Filtration.Models.BlockItemTypes;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.Tests.Models
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestItemFilterScript
|
||||
{
|
||||
[Test]
|
||||
public void Validate_AtLeastOneBlock_Fail_ReturnsListWithCorrectError()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
var script = new ItemFilterScript();
|
||||
|
||||
// Act
|
||||
var result = script.Validate();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.Count(r => r.Contains("A script must have at least one block")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Validate_AtLeastOneBlock_Pass_ReturnsListWithoutError()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
var script = new ItemFilterScript();
|
||||
script.ItemFilterBlocks.Add(new ItemFilterBlock());
|
||||
|
||||
// Act
|
||||
var result = script.Validate();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(0, result.Count(r => r.Contains("A script must have at least one block")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReplaceColors_ReplacesBackgroundColorsCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
var oldColor = new Color {A = 255, R = 255, G = 0, B = 0};
|
||||
var newColor = new Color {A = 255, R = 0, G = 255, B = 100};
|
||||
|
||||
var testInputReplaceColors = new ReplaceColorsParameterSet
|
||||
{
|
||||
OldBackgroundColor = oldColor,
|
||||
NewBackgroundColor = newColor,
|
||||
ReplaceBackgroundColor = true
|
||||
};
|
||||
|
||||
var testInputBlock1 = new ItemFilterBlock();
|
||||
testInputBlock1.BlockItems.Add(new BackgroundColorBlockItem(new Color {A = 255, R = 255, G = 0, B = 0}));
|
||||
var testInputBlock2 = new ItemFilterBlock();
|
||||
testInputBlock2.BlockItems.Add(new BackgroundColorBlockItem(new Color { A = 255, R = 255, G = 1, B = 0 }));
|
||||
var testInputBlock3 = new ItemFilterBlock();
|
||||
testInputBlock3.BlockItems.Add(new BackgroundColorBlockItem(new Color { A = 255, R = 255, G = 0, B = 0 }));
|
||||
|
||||
var script = new ItemFilterScript();
|
||||
|
||||
script.ItemFilterBlocks.Add(testInputBlock1);
|
||||
script.ItemFilterBlocks.Add(testInputBlock2);
|
||||
script.ItemFilterBlocks.Add(testInputBlock3);
|
||||
|
||||
|
||||
// Act
|
||||
script.ReplaceColors(testInputReplaceColors);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(newColor, testInputBlock1.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
|
||||
Assert.AreNotEqual(newColor, testInputBlock2.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
|
||||
Assert.AreEqual(newColor, testInputBlock3.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReplaceColors_OnlyReplacesColorsWhenAllSetParametersMatched()
|
||||
{
|
||||
// Arrange
|
||||
var oldBackgroundColor = new Color { A = 255, R = 255, G = 0, B = 0 };
|
||||
var newBackgroundColor = new Color { A = 255, R = 0, G = 255, B = 100 };
|
||||
|
||||
var oldTextColor = new Color { A = 255, R = 100, G = 0, B = 50 };
|
||||
var newTextColor = new Color { A = 255, R = 101, G = 255, B = 51 };
|
||||
|
||||
var testInputReplaceColors = new ReplaceColorsParameterSet
|
||||
{
|
||||
OldBackgroundColor = oldBackgroundColor,
|
||||
NewBackgroundColor = newBackgroundColor,
|
||||
OldTextColor = oldTextColor,
|
||||
NewTextColor = newTextColor,
|
||||
ReplaceBackgroundColor = true,
|
||||
ReplaceTextColor = true
|
||||
};
|
||||
|
||||
var testInputBlock1 = new ItemFilterBlock();
|
||||
testInputBlock1.BlockItems.Add(new BackgroundColorBlockItem(oldBackgroundColor));
|
||||
testInputBlock1.BlockItems.Add(new TextColorBlockItem(oldTextColor));
|
||||
var testInputBlock2 = new ItemFilterBlock();
|
||||
testInputBlock2.BlockItems.Add(new BackgroundColorBlockItem(oldBackgroundColor));
|
||||
testInputBlock2.BlockItems.Add(new TextColorBlockItem(new Color {A = 1, R = 2, G = 3, B = 4}));
|
||||
|
||||
var script = new ItemFilterScript();
|
||||
script.ItemFilterBlocks.Add(testInputBlock1);
|
||||
script.ItemFilterBlocks.Add(testInputBlock2);
|
||||
|
||||
// Act
|
||||
script.ReplaceColors(testInputReplaceColors);
|
||||
|
||||
// Assert
|
||||
// First test block has had its colors changed
|
||||
Assert.AreEqual(newBackgroundColor, testInputBlock1.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
|
||||
Assert.AreEqual(newTextColor, testInputBlock1.BlockItems.OfType<TextColorBlockItem>().First().Color);
|
||||
|
||||
// Second test block has not had its colors changed
|
||||
Assert.AreEqual(oldBackgroundColor, testInputBlock2.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
|
||||
Assert.AreNotEqual(newTextColor, testInputBlock2.BlockItems.OfType<TextColorBlockItem>().First().Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using Filtration.Repositories;
|
||||
using Filtration.Services;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.IO;
|
||||
using Filtration.Models;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Services;
|
||||
using Filtration.Translators;
|
||||
using Moq;
|
||||
@@ -75,7 +75,7 @@ namespace Filtration.Tests.Services
|
||||
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
|
||||
|
||||
// Act
|
||||
var result = service.DefaultPathOfExileDirectory();
|
||||
service.DefaultPathOfExileDirectory();
|
||||
|
||||
// Assert
|
||||
mockFileSystemService.Verify();
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.Enums;
|
||||
using Filtration.Models;
|
||||
using Filtration.Models.BlockItemBaseTypes;
|
||||
using Filtration.Models.BlockItemTypes;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.Translators;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@@ -49,7 +49,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
|
||||
@@ -93,7 +93,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||
@@ -107,7 +107,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||
@@ -1211,7 +1211,7 @@ namespace Filtration.Tests.Translators
|
||||
public void TranslateItemFilterBlockToString_Section_ReturnsCorrectString()
|
||||
{
|
||||
// Arrange
|
||||
var TestInputSectionText = "Ermagerd it's a section!";
|
||||
const string TestInputSectionText = "Ermagerd it's a section!";
|
||||
var expectedResult = "# Section: " + TestInputSectionText;
|
||||
|
||||
_testUtility.TestBlock = new ItemFilterSection { Description = TestInputSectionText };
|
||||
@@ -1233,14 +1233,14 @@ namespace Filtration.Tests.Translators
|
||||
" DropLevel != 56" + Environment.NewLine +
|
||||
" Quality > 2" + Environment.NewLine +
|
||||
" Rarity = Unique" + Environment.NewLine +
|
||||
" Class \"Body Armour\" \"Gloves\" \"Belt\" \"Two Hand Axes\"" + Environment.NewLine +
|
||||
" BaseType \"Greater Life Flask\" \"Simple Robe\" \"Full Wyrmscale\"" +
|
||||
Environment.NewLine +
|
||||
" Sockets <= 6" + Environment.NewLine +
|
||||
" LinkedSockets >= 4" + Environment.NewLine +
|
||||
" Width = 3" + Environment.NewLine +
|
||||
" Height <= 6" + Environment.NewLine +
|
||||
" Height >= 2" + Environment.NewLine +
|
||||
" Class \"Body Armour\" \"Gloves\" \"Belt\" \"Two Hand Axes\"" + Environment.NewLine +
|
||||
" BaseType \"Greater Life Flask\" \"Simple Robe\" \"Full Wyrmscale\"" +
|
||||
Environment.NewLine +
|
||||
" SetTextColor 255 89 0 56" + Environment.NewLine +
|
||||
" SetBackgroundColor 0 0 0" + Environment.NewLine +
|
||||
" SetBorderColor 255 1 254" + Environment.NewLine +
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Filtration.Enums;
|
||||
using Filtration.Models;
|
||||
using Filtration.Models.BlockItemTypes;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.Translators;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@@ -71,7 +71,7 @@ namespace Filtration.Tests.Translators
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator, mockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var script = translator.TranslateStringToItemFilterScript(testInput);
|
||||
translator.TranslateStringToItemFilterScript(testInput);
|
||||
// Assert
|
||||
// Not crashing out when loading a huge script means this integration test has passed!
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace Filtration.Tests.Translators
|
||||
var testBlock = new ItemFilterBlock();
|
||||
testBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.Equal, 5));
|
||||
|
||||
var BlockOutput = "Test Script Output";
|
||||
const string BlockOutput = "Test Script Output";
|
||||
|
||||
testScript.ItemFilterBlocks.Add(testBlock);
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
|
||||
// Act
|
||||
var result = _testUtility.ScriptTranslator.TranslateItemFilterScriptToString(testScript);
|
||||
_testUtility.ScriptTranslator.TranslateItemFilterScriptToString(testScript);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockItemFilterBlockTranslator.Verify();
|
||||
|
||||
Reference in New Issue
Block a user