Skip to content

Commit

Permalink
Add tests for Castle Windsor
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Bertschi committed Nov 27, 2019
1 parent 1d1874a commit 2ff794b
Show file tree
Hide file tree
Showing 39 changed files with 278 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Castle.Windsor" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Ninject" Version="3.3.4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
using BBT.StructureTools.Compare.Exclusions;
using BBT.StructureTools.Compare.Helper;
using BBT.StructureTools.Tests.Compare.Intention;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

/// <summary>
/// Test for Comparer infrastructure with object attributes.
/// </summary>
[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class ComparerWithObjectAttributeTests
{
#region Members, Setup
private readonly IComparer<TestClass, ITestCompareIntention> testcandidate;

public ComparerWithObjectAttributeTests()
public ComparerWithObjectAttributeTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();

this.testcandidate = kernel.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
this.testcandidate = iocContainer.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
using BBT.StructureTools.Compare.Exclusions;
using BBT.StructureTools.Compare.Helper;
using BBT.StructureTools.Tests.Compare.Intention;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class ComparerWithObjectAttributeWithDistinguishedComparerIntTests
{
#region Members, Setup

private static IComparer<TestWithProperties, ITestCompareIntention> distinguishedComparer;
private readonly IComparer<TestClass, ITestCompareIntention> testcandidate;

public ComparerWithObjectAttributeWithDistinguishedComparerIntTests()
public ComparerWithObjectAttributeWithDistinguishedComparerIntTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();
kernel.RegisterSingleton<ICompareRegistrations<TestWithProperties, ITestCompareIntention>, TestAttributeCompareRegistrations>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestWithProperties, ITestCompareIntention>, TestAttributeCompareRegistrations>();

distinguishedComparer = kernel.GetInstance<IComparer<TestWithProperties, ITestCompareIntention>>();
this.testcandidate = kernel.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
distinguishedComparer = iocContainer.GetInstance<IComparer<TestWithProperties, ITestCompareIntention>>();
this.testcandidate = iocContainer.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
using BBT.StructureTools.Compare.Exclusions;
using BBT.StructureTools.Compare.Helper;
using BBT.StructureTools.Tests.Compare.Intention;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class ComparerWithObjectsAndValueAttributesTests
{
#region Members, Setup
private readonly IComparer<TestClass, ITestCompareIntention> testcandidate;

public ComparerWithObjectsAndValueAttributesTests()
public ComparerWithObjectsAndValueAttributesTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
kernel.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();
iocContainer.Initialize();

this.testcandidate = kernel.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();

this.testcandidate = iocContainer.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
using BBT.StructureTools.Compare.Exclusions;
using BBT.StructureTools.Compare.Helper;
using BBT.StructureTools.Tests.Compare.Intention;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class ComparerWithValueAttributeTests
{
private readonly IComparer<TestClass, ITestCompareIntention> testcandidate;

public ComparerWithValueAttributeTests()
public ComparerWithValueAttributeTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();

this.testcandidate = kernel.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
this.testcandidate = iocContainer.GetInstance<IComparer<TestClass, ITestCompareIntention>>();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,27 @@
using BBT.StructureTools.Compare.Exclusions;
using BBT.StructureTools.Compare.Helper;
using BBT.StructureTools.Tests.Compare.Intention;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class SubComparerUsingComparerTests
{
#region Members, Setup
private static IComparer<TestClassParent, ITestCompareIntention> parentCompare;
private readonly IComparer<TestClassChild, ITestCompareIntention> testcandidate;

public SubComparerUsingComparerTests()
public SubComparerUsingComparerTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<ICompareRegistrations<TestClassChild, ITestCompareIntention>, TestClassChildCompareRegistrations>();
kernel.RegisterSingleton<ICompareRegistrations<TestClassParent, ITestCompareIntention>, TestClassParentCompareRegistrations>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestClassChild, ITestCompareIntention>, TestClassChildCompareRegistrations>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestClassParent, ITestCompareIntention>, TestClassParentCompareRegistrations>();

parentCompare = kernel.GetInstance<IComparer<TestClassParent, ITestCompareIntention>>();
this.testcandidate = kernel.GetInstance<IComparer<TestClassChild, ITestCompareIntention>>();
parentCompare = iocContainer.GetInstance<IComparer<TestClassParent, ITestCompareIntention>>();
this.testcandidate = iocContainer.GetInstance<IComparer<TestClassChild, ITestCompareIntention>>();
}

#endregion
Expand Down
7 changes: 4 additions & 3 deletions src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
using BBT.StructureTools.Compare.Helper;
using BBT.StructureTools.Initialization;
using BBT.StructureTools.Tests.Compare.Intention;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class ToManyComparerTests
{
#region Members, Setup
private readonly IComparer<TestClass, ITestCompareIntention> comparer;

public ToManyComparerTests()
public ToManyComparerTests(IIocContainer iocContainer)
{
var iocContainer = new NinjectIocContainer();
iocContainer.Initialize();

iocContainer.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();
iocContainer.RegisterSingleton<ICompareRegistrations<TestClassListOfChildrenItem, ITestCompareIntention>, TestClassListOfChildrenItemCompareRegistrations>();
Expand Down
1 change: 1 addition & 0 deletions src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Moq;
using NUnit.Framework;

[TestFixture]
public class ConvertHelperTests
{
[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,35 @@
using BBT.StructureTools.Tests.Convert.TestStructure.Source;
using BBT.StructureTools.Tests.Convert.TestStructure.Target;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[NonParallelizable]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class ConvertRootTreeLeafWithMasterDataTests
{
private readonly IConvert<Root, TargetRoot, ITestConvertIntention> testcandidate;

public ConvertRootTreeLeafWithMasterDataTests()
public ConvertRootTreeLeafWithMasterDataTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton(typeof(ITemporalDataDescriptor<>), typeof(TemporalDataDescriptor));
iocContainer.RegisterSingleton(typeof(ITemporalDataDescriptor<TemporalLeafMasterData>), typeof(TemporalDataDescriptor));

kernel.RegisterSingleton<IConvertRegistrations<Root, TargetRoot, ITestConvertIntention>, RootTargetRootConvertRegistrations>();
iocContainer.RegisterSingleton<IConvertRegistrations<Root, TargetRoot, ITestConvertIntention>, RootTargetRootConvertRegistrations>();

kernel.RegisterSingleton<IConvertRegistrations<Tree, TargetTree, ITestConvertIntention>, TreeTargetTreeConvertRegistrations>();
kernel.RegisterSingleton<IConvertRegistrations<TreeMasterData, TargetTree, ITestConvertIntention>, TreeMasterDataToTreeConvertRegistrations>();
iocContainer.RegisterSingleton<IConvertRegistrations<Tree, TargetTree, ITestConvertIntention>, TreeTargetTreeConvertRegistrations>();
iocContainer.RegisterSingleton<IConvertRegistrations<TreeMasterData, TargetTree, ITestConvertIntention>, TreeMasterDataToTreeConvertRegistrations>();

kernel.RegisterSingleton<IConvertRegistrations<Leaf, TargetLeaf, ITestConvertIntention>, LeafTargetLeafConvertRegistrations>();
kernel.RegisterSingleton<IConvertRegistrations<LeafMasterData, TargetLeaf, ITestConvertIntention>, LeafMasterDataTargetLeafConvertRegistrations>();
kernel.RegisterSingleton<IConvertRegistrations<TemporalLeafMasterData, TargetLeaf, ITestConvertIntention>, TemporalLeafMasterDataTemporalLeafDatconvertRegistrations>();
iocContainer.RegisterSingleton<IConvertRegistrations<Leaf, TargetLeaf, ITestConvertIntention>, LeafTargetLeafConvertRegistrations>();
iocContainer.RegisterSingleton<IConvertRegistrations<LeafMasterData, TargetLeaf, ITestConvertIntention>, LeafMasterDataTargetLeafConvertRegistrations>();
iocContainer.RegisterSingleton<IConvertRegistrations<TemporalLeafMasterData, TargetLeaf, ITestConvertIntention>, TemporalLeafMasterDataTemporalLeafDatconvertRegistrations>();

kernel.RegisterSingleton<ICopyRegistrations<ITemporalData>, TemporalDatcopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<ITemporalData>, TemporalDatcopyRegistrations>();

this.testcandidate = kernel.GetInstance<IConvert<Root, TargetRoot, ITestConvertIntention>>();
this.testcandidate = iocContainer.GetInstance<IConvert<Root, TargetRoot, ITestConvertIntention>>();
}

[Test]
Expand Down
15 changes: 8 additions & 7 deletions src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
using BBT.StructureTools.Copy;
using BBT.StructureTools.Copy.Helper;
using BBT.StructureTools.Copy.Processing;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class CopierIntegrationTests
{
#region members and setup
private readonly ICopy<ParentTestClass> testcandidate;

public CopierIntegrationTests()
public CopierIntegrationTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
kernel.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();
kernel.RegisterSingleton<ICopyRegistrations<IChildTestClass2>, ChildTestClass2CopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<IChildTestClass2>, ChildTestClass2CopyRegistrations>();

this.testcandidate = kernel.GetInstance<ICopy<IParentTestClass>>();
this.testcandidate = iocContainer.GetInstance<ICopy<IParentTestClass>>();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
using BBT.StructureTools.Copy;
using BBT.StructureTools.Copy.Helper;
using BBT.StructureTools.Copy.Strategy;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class CopyOperationCreateToManyFromGenericStrategyIntTests
{
#region setup

private readonly ICopy<ParentTestClass> testcandidate;

public CopyOperationCreateToManyFromGenericStrategyIntTests()
public CopyOperationCreateToManyFromGenericStrategyIntTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
kernel.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();
kernel.RegisterSingleton<IGenericStrategyProvider<TestStrategy, IChildTestClass>, TestFactory>();
kernel.RegisterSingleton<ITestStrategy, TestStrategy>();
iocContainer.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();
iocContainer.RegisterSingleton<IGenericStrategyProvider<TestStrategy, IChildTestClass>, TestFactory>();
iocContainer.RegisterSingleton<ITestStrategy, TestStrategy>();

this.testcandidate = kernel.GetInstance<ICopy<IParentTestClass>>();
this.testcandidate = iocContainer.GetInstance<ICopy<IParentTestClass>>();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
using BBT.StructureTools.Copy;
using BBT.StructureTools.Copy.Helper;
using BBT.StructureTools.Copy.Strategy;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests
{
#region setup

private readonly ICopy<IParentTestClass> testcandidate;

public CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests()
public CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<IGenericStrategyProvider<TestStrategy, IChildTestClass>, TestFactory>();
kernel.RegisterSingleton<ITestStrategy, TestStrategy>();
kernel.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
kernel.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();
iocContainer.RegisterSingleton<IGenericStrategyProvider<TestStrategy, IChildTestClass>, TestFactory>();
iocContainer.RegisterSingleton<ITestStrategy, TestStrategy>();
iocContainer.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();

this.testcandidate = kernel.GetInstance<ICopy<IParentTestClass>>();
this.testcandidate = iocContainer.GetInstance<ICopy<IParentTestClass>>();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@
using BBT.StructureTools;
using BBT.StructureTools.Copy;
using BBT.StructureTools.Copy.Helper;
using BBT.StructureTools.Tests.TestTools;
using BBT.StructureTools.Tests.TestTools.IoC;
using FluentAssertions;
using NUnit.Framework;

[TestFixture]
[TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")]
public class CopyOperationCreateToManyWithReverseRelationIntTests
{
#region members and setup
private readonly ICopy<IParentTestClass> testcandidate;

public CopyOperationCreateToManyWithReverseRelationIntTests()
public CopyOperationCreateToManyWithReverseRelationIntTests(IIocContainer iocContainer)
{
var kernel = new NinjectIocContainer();
iocContainer.Initialize();

kernel.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
kernel.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<IParentTestClass>, TestClassCopyRegistrations>();
iocContainer.RegisterSingleton<ICopyRegistrations<IChildTestClass>, ChildTestClassCopyRegistrations>();

this.testcandidate = kernel.GetInstance<ICopy<IParentTestClass>>();
this.testcandidate = iocContainer.GetInstance<ICopy<IParentTestClass>>();
}

#endregion
Expand Down
Loading

0 comments on commit 2ff794b

Please sign in to comment.