Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-22) Add tests for Castle Windsor #32

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add tests for Castle Windsor
Marco Bertschi committed Nov 28, 2019
commit d4064026766042fe23f29a9fd1435d52fd66f91e
4 changes: 1 addition & 3 deletions src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj
Original file line number Diff line number Diff line change
@@ -18,11 +18,9 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<None Remove="Compare\ve-B655.tmp" />
</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" />
Original file line number Diff line number Diff line change
@@ -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;
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
@@ -40,7 +41,7 @@ public void Equals_WhenSameInstance_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClass, testClass);
var result = this.testCandidate.Equals(testClass, testClass);

// Assert
result.Should().BeTrue();
@@ -57,7 +58,7 @@ public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClass, testClass);
var result = this.testCandidate.Equals(testClass, testClass);

// Assert
result.Should().BeTrue();
@@ -72,7 +73,7 @@ public void Equals_WhenAttributeObjectsEqual_MustReturnTrue()
var testClassB = new TestClass { TestAttribute1 = testAttribute };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -88,7 +89,7 @@ public void Equals_WhenAttributeObjectsNotEqual_MustReturnFalse()
var testClassB = new TestClass { TestAttribute1 = testAttribute2 };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeFalse();
@@ -103,7 +104,7 @@ public void Equals_WhenAttributeObjectsNotEqualButNotRegistered_MustReturnTrue()
var testClassB = new TestClass { TestAttribute2 = testAttribute };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -124,7 +125,7 @@ public void Equals_WhenAttributeObjectsNotEqualButExcluded_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClassA, testClassB, System.Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);
var result = this.testCandidate.Equals(testClassA, testClassB, System.Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);

// Assert
result.Should().BeTrue();
Original file line number Diff line number Diff line change
@@ -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;
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
@@ -45,7 +46,7 @@ public void Equals_WhenSameInstance_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClass, testClass);
var result = this.testCandidate.Equals(testClass, testClass);

// Assert
result.Should().BeTrue();
@@ -65,7 +66,7 @@ public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClass, testClass);
var result = this.testCandidate.Equals(testClass, testClass);

// Assert
result.Should().BeTrue();
@@ -83,7 +84,7 @@ public void Equals_WhenAttributeObjectsEqual_MustReturnTrue()
var testClassB = new TestClass { TestAttribute = testAttribute };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -102,7 +103,7 @@ public void Equals_WhenBaseModelAttributeObjectsNotEqualButHaveSameValue_MustRet
var testClassB = new TestClass { TestAttribute = testAttribute2 };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -121,7 +122,7 @@ public void Equals_WhenBaseModelAttributeObjectsNotEqualAndHaveDifferentValue_Mu
var testClassB = new TestClass { TestAttribute = testAttribute2 };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeFalse();
@@ -140,7 +141,7 @@ public void Equals_WhenAttributeObjectsNotEqualButNotRegistered_MustReturnTrue()
var testClassB = new TestClass { TestAttribute = testAttribute2 };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -164,7 +165,7 @@ public void Equals_WhenAttributeObjectsNotEqualButExcluded_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClassA, testClassB, Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);
var result = this.testCandidate.Equals(testClassA, testClassB, Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);

// Assert
result.Should().BeTrue();
Original file line number Diff line number Diff line change
@@ -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;
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
@@ -38,7 +40,7 @@ public void Equals_WhenSameInstance_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClass, testClass);
var result = this.testCandidate.Equals(testClass, testClass);

// Assert
result.Should().BeTrue();
@@ -56,7 +58,7 @@ public void Equals_WhenSameInstanceAndObjectAttributeNullButValueNot_MustReturnT
};

// Act
var result = this.testcandidate.Equals(testClass, testClass);
var result = this.testCandidate.Equals(testClass, testClass);

// Assert
result.Should().BeTrue();
@@ -79,7 +81,7 @@ public void Equals_WhenAttributeObjectsAndValueEqual_MustReturnTrue()
};

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -102,7 +104,7 @@ public void Equals_WhenAttributeObjectsButNotValueEqual_MustReturnFalse()
};

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeFalse();
@@ -126,7 +128,7 @@ public void Equals_WhenAttributeObjectsNotButValueEqual_MustReturnFalse()
};

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeFalse();
@@ -150,7 +152,7 @@ public void Equals_WhenAttributeObjectsAndValuesNotEqualButNotRegistered_MustRet
};

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -181,7 +183,7 @@ public void Equals_WhenAttributeObjectsAndValuesNotEqualButExcluded_MustReturnTr
};

// Act
var result = this.testcandidate.Equals(testClassA, testClassB, Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);
var result = this.testCandidate.Equals(testClassA, testClassB, Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);

// Assert
result.Should().BeTrue();
Original file line number Diff line number Diff line change
@@ -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;
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]
@@ -31,7 +32,7 @@ public void Equals_WhenSameInstance_MustReturnTrue()
var testClass = new TestClass { Value1 = 45 };

// Act
var result = this.testcandidate.Equals(testClass, testClass);
var result = this.testCandidate.Equals(testClass, testClass);

// Assert
result.Should().BeTrue();
@@ -45,7 +46,7 @@ public void Equals_WhenAttributeValuesEqual_MustReturnTrue()
var testClassB = new TestClass { Value1 = 45 };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -59,7 +60,7 @@ public void Equals_WhenAttributeValuesNotEqual_MustReturnFalse()
var testClassB = new TestClass { Value1 = 44 };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeFalse();
@@ -73,7 +74,7 @@ public void Equals_WhenAttributeValuesNotEqualButNotRegistered_MustReturnTrue()
var testClassB = new TestClass { Value2 = 44 };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB);
var result = this.testCandidate.Equals(testClassA, testClassB);

// Assert
result.Should().BeTrue();
@@ -88,7 +89,7 @@ public void Equals_WhenAttributeValuesNotEqualButExcluded_MustReturnTrue()
var comparerExclusions = new List<IComparerExclusion> { new PropertyComparerExclusion<TestClass>(x => x.Value1) };

// Act
var result = this.testcandidate.Equals(testClassA, testClassB, Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);
var result = this.testCandidate.Equals(testClassA, testClassB, Array.Empty<IBaseAdditionalProcessing>(), comparerExclusions);

// Assert
result.Should().BeTrue();
Loading