Added untracked files

This commit is contained in:
Ben 2015-07-02 17:57:43 +01:00
parent c3d11da155
commit 0bc3cac585
19 changed files with 770 additions and 0 deletions

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.Common.Tests</RootNamespace>
<AssemblyName>Filtration.Common.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1506.2515\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1506.2515" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
</packages>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8CB44F28-2956-4C2A-9314-72727262EDD4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.Common</RootNamespace>
<AssemblyName>Filtration.Common</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor">
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\FileSystemService.cs" />
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
<Compile Include="ViewModels\PaneViewModel.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4AAC3BEB-1DC1-483E-9D11-0E9334E80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,18 @@
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Filtration.Common.Services;
namespace Filtration.Common.WindsorInstallers
{
public class ServicesInstaller :IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Component.For<IFileSystemService>()
.ImplementedBy<FileSystemService>()
.LifeStyle.Singleton);
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
</packages>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0F333344-7695-47B2-B0E6-172E4DE74819}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.Interface</RootNamespace>
<AssemblyName>Filtration.Interface</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="IDocument.cs" />
<Compile Include="IEditableDocument.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,9 @@
namespace Filtration.Interface
{
public interface IEditableDocument : IDocument
{
bool IsDirty { get; }
void Save();
void SaveAs();
}
}

View File

@ -0,0 +1,42 @@
using NUnit.Framework;
namespace Filtration.ObjectModel.Tests
{
[TestFixture]
public class TestItemFilterBlockGroup
{
[Test]
public void ToString_ReturnsFullBlockHierarchy()
{
// Arrange
const string ExpectedResult = "Child 1 Block Group - Child 2 Block Group";
var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup);
var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup);
// Act
var result = child2BlockGroup.ToString();
// Assert
Assert.AreEqual(ExpectedResult, result);
}
[Test]
public void ToString_AddsTildeForAdvancedBlock()
{
// Arrange
const string ExpectedResult = "~Child 1 Block Group - Child 2 Block Group";
var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup, true);
var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup);
// Act
var result = child2BlockGroup.ToString();
// Assert
Assert.AreEqual(ExpectedResult, result);
}
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1506.2016" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
</packages>

View File

@ -0,0 +1,121 @@
using System.Collections.Generic;
using Filtration.ObjectModel;
using Filtration.Translators;
using NUnit.Framework;
namespace Filtration.Tests.Translators
{
[TestFixture]
public class TestBlockGroupHierarchyBuilder
{
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_ReturnsBlockGroupWithCorrectName()
{
// Arrange
var inputStrings = new List<string> {"Block Group", "Sub Block Group"};
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Sub Block Group", result.GroupName);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_SingleBlockGroup()
{
// Arrange
var inputStrings = new List<string> { "Block Group" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Block Group", result.GroupName);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_AdvancedBlockGroup_MarksBlockGroupAsAdvanced()
{
// Arrange
var inputStrings = new List<string> { "~Block Group" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Block Group", result.GroupName);
Assert.AreEqual(true, result.Advanced);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_AdvancedBlockGroup_ChildrenAreCreatedAsAdvanced()
{
// Arrange
var inputStrings = new List<string> { "~Advanced Block Group", "This should be advanced too" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual(true, result.Advanced);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_ExistingAdvancedBlockGroup_SetsParentCorrectly()
{
// Arrange
var inputStrings = new List<string> { "~Block Group" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var subBlock = new ItemFilterBlockGroup("Block Group", rootBlock, true);
rootBlock.ChildGroups.Add(subBlock);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Block Group", result.GroupName);
Assert.AreEqual(true, result.Advanced);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_MultipleBlockGroups()
{
// Arrange
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var inputStrings = new List<string> { "Block Group" };
builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
inputStrings = new List<string> { "Block Group 2" };
builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
inputStrings = new List<string> { "Block Group", "Sub Block Group" };
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(2, rootBlock.ChildGroups.Count);
Assert.AreEqual("Sub Block Group", result.GroupName);
}
}
}

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{450AC313-BF25-4BFD-A066-9F39F026FDCF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.ThemeEditor.Tests</RootNamespace>
<AssemblyName>Filtration.ThemeEditor.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1506.2515\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models\TestTheme.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\TestThemeProvider.cs" />
<Compile Include="Services\TestThemeService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ThemeEditor\Filtration.ThemeEditor.csproj">
<Project>{41b8f5c2-65aa-42f0-a20b-6f95b13a9f48}</Project>
<Name>Filtration.ThemeEditor</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,78 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using NUnit.Framework;
namespace Filtration.ThemeEditor.Tests.Models
{
[TestFixture]
public class TestTheme
{
[Test]
public void ComponentExists_ComponentDoesExist_ReturnsTrue()
{
// Arrange
var theme = new Theme();
var testInputComponentTargetType = ThemeComponentType.TextColor;
const string TestInputComponentName = "test";
theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color());
// Act
var result = theme.ComponentExists(testInputComponentTargetType, TestInputComponentName);
// Assert
Assert.AreEqual(true, result);
}
[Test]
public void ComponentExists_ComponentDoesNotExist_DifferentNameSameType_ReturnsFalse()
{
// Arrange
var theme = new Theme();
var testInputComponentTargetType = ThemeComponentType.TextColor;
const string TestInputComponentName = "test";
theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color());
// Act
var result = theme.ComponentExists(testInputComponentTargetType, "blah");
// Assert
Assert.AreEqual(false, result);
}
[Test]
public void ComponentExists_ComponentDoesNotExist_DifferentTypeSameName_ReturnsFalse()
{
// Arrange
var theme = new Theme();
var testInputComponentTargetType = ThemeComponentType.TextColor;
const string TestInputComponentName = "test";
theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color());
// Act
var result = theme.ComponentExists(ThemeComponentType.BorderColor, TestInputComponentName);
// Assert
Assert.AreEqual(false, result);
}
[Test]
public void ComponentExists_ComponentDoesNotExist_NoComponents_ReturnsFalse()
{
// Arrange
var theme = new Theme();
// Act
var result = theme.ComponentExists(ThemeComponentType.BorderColor, "test");
// Assert
Assert.AreEqual(false, result);
}
}
}

View File

@ -0,0 +1,67 @@
using System.Windows.Media;
using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.ThemeEditor.Services;
using NUnit.Framework;
namespace Filtration.ThemeEditor.Tests.Services
{
[TestFixture]
public class TestThemeService
{
[Test]
public void ApplyThemeToScript_SingleBlock_ReplacesColor()
{
// Arrange
var testInputBlockItem = new TextColorBlockItem();
var testInputBlock = new ItemFilterBlock();
testInputBlock.BlockItems.Add(testInputBlockItem);
var testInputScript = new ItemFilterScript();
testInputScript.ItemFilterBlocks.Add(testInputBlock);
var testInputTheme = new Theme();
var testInputThemeComponentColor = new Color{ R = 255, G = 0, B = 1 };
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputThemeComponent;
var service = new ThemeService();
// Act
service.ApplyThemeToScript(testInputTheme, testInputScript);
// Assert
Assert.AreEqual(testInputThemeComponentColor, testInputBlockItem.Color);
}
[Test]
public void ApplyThemeToScript_SingleBlockDifferentComponentName_DoesNotReplaceColour()
{
// Arrange
var testInputBlockItem = new TextColorBlockItem();
var testInputBlock = new ItemFilterBlock();
testInputBlock.BlockItems.Add(testInputBlockItem);
var testInputScript = new ItemFilterScript();
testInputScript.ItemFilterBlocks.Add(testInputBlock);
var testInputTheme = new Theme();
var testInputThemeComponentColor = new Color { R = 255, G = 0, B = 1 };
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
var testInputBlockItemThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Different Component", testInputThemeComponentColor);
testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputBlockItemThemeComponent;
var service = new ThemeService();
// Act
service.ApplyThemeToScript(testInputTheme, testInputScript);
// Assert
Assert.AreNotEqual(testInputThemeComponentColor, testInputBlockItem.Color);
}
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1506.2515" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
</packages>

View File

@ -0,0 +1,30 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
namespace Filtration.ThemeEditor.Converters
{
public class ThemeComponentTypeToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return string.Empty;
}
var type = (ThemeComponentType) value;
return type.GetAttributeDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,40 @@
using System.IO;
using System.Xml.Serialization;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ThemeEditor.Services
{
internal interface IThemePersistenceService
{
Theme LoadTheme(string filePath);
void SaveTheme(Theme theme, string filePath);
}
internal class ThemePersistenceService : IThemePersistenceService
{
public Theme LoadTheme(string filePath)
{
var xmlSerializer = new XmlSerializer(typeof(Theme));
Theme loadedTheme;
using (Stream reader = new FileStream(filePath, FileMode.Open))
{
loadedTheme = (Theme)xmlSerializer.Deserialize(reader);
}
loadedTheme.FilePath = filePath;
return loadedTheme;
}
public void SaveTheme(Theme theme, string filePath)
{
var xmlSerializer = new XmlSerializer(typeof(Theme));
using (Stream writer = new FileStream(filePath, FileMode.Create))
{
xmlSerializer.Serialize(writer, theme);
}
}
}
}

View File

@ -0,0 +1,19 @@
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
namespace Filtration.ThemeEditor.ViewModels
{
public interface IThemeComponentViewModel
{
string ComponentName { get; set; }
ThemeComponentType ComponentType { get; set; }
Color Color { get; set; }
}
public class ThemeComponentViewModel : IThemeComponentViewModel
{
public string ComponentName { get; set; }
public ThemeComponentType ComponentType { get; set; }
public Color Color { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace Filtration.Converters
{
internal class HashSignRemovalConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var inputString = (string) value;
return inputString.Replace("#", string.Empty);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,24 @@
using System.Windows;
using System.Windows.Controls;
namespace Filtration.Views.ToolPanes
{
public partial class BlockGroupBrowserView
{
public BlockGroupBrowserView()
{
InitializeComponent();
}
private void BlockGroupCheckBox_Clicked(object sender, RoutedEventArgs e)
{
// Prevents the user from putting a ThreeState checkbox into the indeterminate state
// allowing the indeterminate state to only be set by the object itself.
var cb = e.Source as CheckBox;
if (cb != null && !cb.IsChecked.HasValue)
{
cb.IsChecked = false;
}
}
}
}