From ad835e4893325863af32daf741640c428c7641b2 Mon Sep 17 00:00:00 2001 From: Marco Bertschi Date: Wed, 27 Nov 2019 14:01:31 +0100 Subject: [PATCH 1/2] Use NUnit --- src/BBT.StructureTools.Tests/AssemblyInfo.cs | 3 - .../BBT.StructureTools.Tests.csproj | 9 +- .../ComparerWithObjectAttributeTests.cs | 42 ++++---- ...ributeWithDistinguishedComparerIntTests.cs | 58 +++++------ ...parerWithObjectsAndValueAttributesTests.cs | 49 +++++----- .../ComparerWithValueAttributeTests.cs | 20 ++-- .../Compare/SubComparerUsingComparerTests.cs | 26 ++--- .../Compare/ToManyComparerTests.cs | 96 +++++++++---------- .../Convert/ConvertHelperTests.cs | 14 +-- .../ConvertRootTreeLeafWithMasterDataTests.cs | 26 ++--- .../Copy/CopierIntegrationTests.cs | 20 ++-- ...CreateToManyFromGenericStrategyIntTests.cs | 23 +++-- ...ericStrategyWithReverseRelationIntTests.cs | 22 ++--- ...CreateToManyWithReverseRelationIntTests.cs | 23 +++-- ...nCreateToOneWithReverseRelationIntTests.cs | 17 ++-- ...erationCrossReferenceProcessingIntTests.cs | 16 ++-- ...CopyOperationInlineValueProcessingTests.cs | 12 +-- .../Copy/CopyOperationIntTests.cs | 16 ++-- ...OperationRegisterCreateFromFactoryTests.cs | 16 ++-- .../Copy/CopyOperationSubCopyIntTests.cs | 18 ++-- ...rationPostProcessingUsingParamsIntTests.cs | 12 +-- ...PostProcessingWithoutUsingParamsIntTest.cs | 12 +-- .../TestTools/IoC/IIocContainer.cs | 47 +++++++++ .../TestTools/IoC/NinjectIocContainer.cs | 68 +++++++++++++ .../TestTools/TestIoContainer.cs | 56 ----------- 25 files changed, 387 insertions(+), 334 deletions(-) create mode 100644 src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs create mode 100644 src/BBT.StructureTools.Tests/TestTools/IoC/NinjectIocContainer.cs delete mode 100644 src/BBT.StructureTools.Tests/TestTools/TestIoContainer.cs diff --git a/src/BBT.StructureTools.Tests/AssemblyInfo.cs b/src/BBT.StructureTools.Tests/AssemblyInfo.cs index 66e9ed0..7fdc6a7 100644 --- a/src/BBT.StructureTools.Tests/AssemblyInfo.cs +++ b/src/BBT.StructureTools.Tests/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Runtime.InteropServices; -using Xunit; // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from @@ -8,5 +7,3 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("e03aad10-b9e8-401c-9a10-d74d814bf0a6")] - -[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)] diff --git a/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj b/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj index c3b850b..5ab6eb0 100644 --- a/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj +++ b/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj @@ -18,21 +18,22 @@ pdbonly + + + - - - all - all all + + all diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs index 2dcd989..194e793 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs @@ -7,12 +7,12 @@ using BBT.StructureTools.Tests.Compare.Intention; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; /// /// Test for Comparer infrastructure with object attributes. /// + [TestFixture] public class ComparerWithObjectAttributeTests { #region Members, Setup @@ -20,23 +20,23 @@ public class ComparerWithObjectAttributeTests public ComparerWithObjectAttributeTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCompareRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion - [Fact] + [Test] public void Equals_WhenSameInstance_MustReturnTrue() { // Arrange var testClass = new TestClass { // Explicit instance init on purpose - TestAttribute1 = new TestAttribute(), + TestAttribute1 = new TestObjProperty(), }; // Act @@ -46,7 +46,7 @@ public void Equals_WhenSameInstance_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue() { // Arrange @@ -63,11 +63,11 @@ public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsEqual_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); + var testAttribute = new TestObjProperty(); var testClassA = new TestClass { TestAttribute1 = testAttribute }; var testClassB = new TestClass { TestAttribute1 = testAttribute }; @@ -78,12 +78,12 @@ public void Equals_WhenAttributeObjectsEqual_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsNotEqual_MustReturnFalse() { // Arrange - var testAttribute = new TestAttribute(); - var testAttribute2 = new TestAttribute(); + var testAttribute = new TestObjProperty(); + var testAttribute2 = new TestObjProperty(); var testClassA = new TestClass { TestAttribute1 = testAttribute }; var testClassB = new TestClass { TestAttribute1 = testAttribute2 }; @@ -94,11 +94,11 @@ public void Equals_WhenAttributeObjectsNotEqual_MustReturnFalse() result.Should().BeFalse(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsNotEqualButNotRegistered_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); + var testAttribute = new TestObjProperty(); var testClassA = new TestClass { TestAttribute2 = testAttribute }; var testClassB = new TestClass { TestAttribute2 = testAttribute }; @@ -109,12 +109,12 @@ public void Equals_WhenAttributeObjectsNotEqualButNotRegistered_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsNotEqualButExcluded_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); - var testAttribute2 = new TestAttribute(); + var testAttribute = new TestObjProperty(); + var testAttribute2 = new TestObjProperty(); var testClassA = new TestClass { TestAttribute1 = testAttribute }; var testClassB = new TestClass { TestAttribute1 = testAttribute2 }; var comparerExclusions = new List @@ -133,12 +133,12 @@ public void Equals_WhenAttributeObjectsNotEqualButExcluded_MustReturnTrue() #region private test classes and test class helpers private class TestClass { - public TestAttribute TestAttribute1 { get; set; } + public TestObjProperty TestAttribute1 { get; set; } - public TestAttribute TestAttribute2 { get; set; } + public TestObjProperty TestAttribute2 { get; set; } } - private class TestAttribute + private class TestObjProperty { } diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs index b1e152d..c9fbd1d 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs @@ -8,25 +8,25 @@ using BBT.StructureTools.Tests.Compare.Intention; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class ComparerWithObjectAttributeWithDistinguishedComparerIntTests { #region Members, Setup - private static IComparer distinguishedComparer; + private static IComparer distinguishedComparer; private readonly IComparer testcandidate; public ComparerWithObjectAttributeWithDistinguishedComparerIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCompareRegistrations>(); + kernel.RegisterSingleton, TestAttributeCompareRegistrations>(); - distinguishedComparer = kernel.Get>(); - this.testcandidate = kernel.Get>(); + distinguishedComparer = kernel.GetInstance>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -34,14 +34,14 @@ public ComparerWithObjectAttributeWithDistinguishedComparerIntTests() /// /// Tests IComparer.Equals. /// - [Fact] + [Test] public void Equals_WhenSameInstance_MustReturnTrue() { // Arrange var testClass = new TestClass { // Explicit instance init on purpose - TestAttribute = new TestAttribute(), + TestAttribute = new TestWithProperties(), }; // Act @@ -54,7 +54,7 @@ public void Equals_WhenSameInstance_MustReturnTrue() /// /// Tests IComparer.Equals. /// - [Fact] + [Test] public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue() { // Arrange @@ -74,11 +74,11 @@ public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue() /// /// Tests IComparer.Equals. /// - [Fact] + [Test] public void Equals_WhenAttributeObjectsEqual_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); + var testAttribute = new TestWithProperties(); var testClassA = new TestClass { TestAttribute = testAttribute }; var testClassB = new TestClass { TestAttribute = testAttribute }; @@ -92,12 +92,12 @@ public void Equals_WhenAttributeObjectsEqual_MustReturnTrue() /// /// Tests IComparer.Equals. /// - [Fact] + [Test] public void Equals_WhenBaseModelAttributeObjectsNotEqualButHaveSameValue_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); - var testAttribute2 = new TestAttribute(); + var testAttribute = new TestWithProperties(); + var testAttribute2 = new TestWithProperties(); var testClassA = new TestClass { TestAttribute = testAttribute }; var testClassB = new TestClass { TestAttribute = testAttribute2 }; @@ -111,12 +111,12 @@ public void Equals_WhenBaseModelAttributeObjectsNotEqualButHaveSameValue_MustRet /// /// Tests IComparer.Equals. /// - [Fact] + [Test] public void Equals_WhenBaseModelAttributeObjectsNotEqualAndHaveDifferentValue_MustReturnFalse() { // Arrange - var testAttribute = new TestAttribute { TestValue1 = 55 }; - var testAttribute2 = new TestAttribute(); + var testAttribute = new TestWithProperties { TestValue1 = 55 }; + var testAttribute2 = new TestWithProperties(); var testClassA = new TestClass { TestAttribute = testAttribute }; var testClassB = new TestClass { TestAttribute = testAttribute2 }; @@ -130,12 +130,12 @@ public void Equals_WhenBaseModelAttributeObjectsNotEqualAndHaveDifferentValue_Mu /// /// Tests IComparer.Equals. /// - [Fact] + [Test] public void Equals_WhenAttributeObjectsNotEqualButNotRegistered_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute() { TestValue2 = 2 }; - var testAttribute2 = new TestAttribute() { TestValue2 = 1 }; + var testAttribute = new TestWithProperties() { TestValue2 = 2 }; + var testAttribute2 = new TestWithProperties() { TestValue2 = 1 }; var testClassA = new TestClass { TestAttribute = testAttribute }; var testClassB = new TestClass { TestAttribute = testAttribute2 }; @@ -149,12 +149,12 @@ public void Equals_WhenAttributeObjectsNotEqualButNotRegistered_MustReturnTrue() /// /// Tests IComparer.Equals. /// - [Fact] + [Test] public void Equals_WhenAttributeObjectsNotEqualButExcluded_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute() { TestValue1 = 2 }; - var testAttribute2 = new TestAttribute() { TestValue1 = 1 }; + var testAttribute = new TestWithProperties() { TestValue1 = 2 }; + var testAttribute2 = new TestWithProperties() { TestValue1 = 1 }; var testClassA = new TestClass { TestAttribute = testAttribute }; var testClassB = new TestClass { TestAttribute = testAttribute2 }; var comparerExclusions = new List @@ -174,19 +174,19 @@ public void Equals_WhenAttributeObjectsNotEqualButExcluded_MustReturnTrue() private class TestClass { - public TestAttribute TestAttribute { get; set; } + public TestWithProperties TestAttribute { get; set; } } - private class TestAttribute + private class TestWithProperties { public int TestValue1 { get; set; } public int TestValue2 { get; set; } } - private class TestAttributeCompareRegistrations : ICompareRegistrations + private class TestAttributeCompareRegistrations : ICompareRegistrations { - public void DoRegistrations(IEqualityComparerHelperRegistration registrations) + public void DoRegistrations(IEqualityComparerHelperRegistration registrations) { registrations.Should().NotBeNull(); diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs index 784147a..8e120e4 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs @@ -8,9 +8,9 @@ using BBT.StructureTools.Tests.Compare.Intention; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class ComparerWithObjectsAndValueAttributesTests { #region Members, Setup @@ -18,23 +18,22 @@ public class ComparerWithObjectsAndValueAttributesTests public ComparerWithObjectsAndValueAttributesTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); + kernel.RegisterSingleton, TestClassCompareRegistrations>(); - kernel.Bind>().To(); - - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion - [Fact] + [Test] public void Equals_WhenSameInstance_MustReturnTrue() { // Arrange var testClass = new TestClass { // Explicit instance init on purpose - TestAttribute1 = new TestAttribute(), + TestAttribute1 = new TestWithProperties(), TestValue2 = 1, }; @@ -45,7 +44,7 @@ public void Equals_WhenSameInstance_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenSameInstanceAndObjectAttributeNullButValueNot_MustReturnTrue() { // Arrange @@ -63,11 +62,11 @@ public void Equals_WhenSameInstanceAndObjectAttributeNullButValueNot_MustReturnT result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsAndValueEqual_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); + var testAttribute = new TestWithProperties(); var testClassA = new TestClass { TestAttribute1 = testAttribute, @@ -86,11 +85,11 @@ public void Equals_WhenAttributeObjectsAndValueEqual_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsButNotValueEqual_MustReturnFalse() { // Arrange - var testAttribute = new TestAttribute(); + var testAttribute = new TestWithProperties(); var testClassA = new TestClass { TestAttribute1 = testAttribute, @@ -109,12 +108,12 @@ public void Equals_WhenAttributeObjectsButNotValueEqual_MustReturnFalse() result.Should().BeFalse(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsNotButValueEqual_MustReturnFalse() { // Arrange - var testAttribute = new TestAttribute(); - var testAttribute2 = new TestAttribute(); + var testAttribute = new TestWithProperties(); + var testAttribute2 = new TestWithProperties(); var testClassA = new TestClass { TestAttribute1 = testAttribute, @@ -133,12 +132,12 @@ public void Equals_WhenAttributeObjectsNotButValueEqual_MustReturnFalse() result.Should().BeFalse(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsAndValuesNotEqualButNotRegistered_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); - var testAttribute2 = new TestAttribute(); + var testAttribute = new TestWithProperties(); + var testAttribute2 = new TestWithProperties(); var testClassA = new TestClass { TestAttribute2 = testAttribute, @@ -157,12 +156,12 @@ public void Equals_WhenAttributeObjectsAndValuesNotEqualButNotRegistered_MustRet result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeObjectsAndValuesNotEqualButExcluded_MustReturnTrue() { // Arrange - var testAttribute = new TestAttribute(); - var testAttribute2 = new TestAttribute(); + var testAttribute = new TestWithProperties(); + var testAttribute2 = new TestWithProperties(); var testClassA = new TestClass { TestAttribute1 = testAttribute, @@ -191,16 +190,16 @@ public void Equals_WhenAttributeObjectsAndValuesNotEqualButExcluded_MustReturnTr #region private test classes and test class helpers private class TestClass { - public TestAttribute TestAttribute1 { get; set; } + public TestWithProperties TestAttribute1 { get; set; } - public TestAttribute TestAttribute2 { get; set; } + public TestWithProperties TestAttribute2 { get; set; } public int TestValue1 { get; set; } public int TestValue2 { get; set; } } - private class TestAttribute + private class TestWithProperties { } diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs index 8f6bf0b..36f3284 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs @@ -8,23 +8,23 @@ using BBT.StructureTools.Tests.Compare.Intention; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class ComparerWithValueAttributeTests { private readonly IComparer testcandidate; public ComparerWithValueAttributeTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCompareRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } - [Fact] + [Test] public void Equals_WhenSameInstance_MustReturnTrue() { // Arrange @@ -37,7 +37,7 @@ public void Equals_WhenSameInstance_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeValuesEqual_MustReturnTrue() { // Arrange @@ -51,7 +51,7 @@ public void Equals_WhenAttributeValuesEqual_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeValuesNotEqual_MustReturnFalse() { // Arrange @@ -65,7 +65,7 @@ public void Equals_WhenAttributeValuesNotEqual_MustReturnFalse() result.Should().BeFalse(); } - [Fact] + [Test] public void Equals_WhenAttributeValuesNotEqualButNotRegistered_MustReturnTrue() { // Arrange @@ -79,7 +79,7 @@ public void Equals_WhenAttributeValuesNotEqualButNotRegistered_MustReturnTrue() result.Should().BeTrue(); } - [Fact] + [Test] public void Equals_WhenAttributeValuesNotEqualButExcluded_MustReturnTrue() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs b/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs index 45ad650..61dc2a9 100644 --- a/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs @@ -8,9 +8,9 @@ using BBT.StructureTools.Tests.Compare.Intention; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class SubComparerUsingComparerTests { #region Members, Setup @@ -19,13 +19,13 @@ public class SubComparerUsingComparerTests public SubComparerUsingComparerTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassChildCompareRegistrations>(); + kernel.RegisterSingleton, TestClassParentCompareRegistrations>(); - parentCompare = kernel.Get>(); - this.testcandidate = kernel.Get>(); + parentCompare = kernel.GetInstance>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -33,7 +33,7 @@ public SubComparerUsingComparerTests() /// /// Tests equals. /// - [Fact] + [Test] public void Equals_SameInstance_MustReturnTrue() { // Arrange @@ -49,7 +49,7 @@ public void Equals_SameInstance_MustReturnTrue() /// /// Tests equals. /// - [Fact] + [Test] public void Equals_DifferentInstancesSameAttributes_MustReturnTrue() { // Arrange @@ -72,7 +72,7 @@ public void Equals_DifferentInstancesSameAttributes_MustReturnTrue() /// /// Tests equals. /// - [Fact] + [Test] public void Equals_DifferentInstancesNotSameAttributes_MustReturnFalse() { // Arrange @@ -95,7 +95,7 @@ public void Equals_DifferentInstancesNotSameAttributes_MustReturnFalse() /// /// Tests equals. /// - [Fact] + [Test] public void Equals_DifferentInstancesNotSameAttributesNotRegistered_MustReturnTrue() { // Arrange @@ -118,7 +118,7 @@ public void Equals_DifferentInstancesNotSameAttributesNotRegistered_MustReturnTr /// /// Tests equals. /// - [Fact] + [Test] public void Equals_DifferentInstancesNotSameAttributesButExcludedByParent_MustReturnTrue() { // Arrange @@ -146,7 +146,7 @@ public void Equals_DifferentInstancesNotSameAttributesButExcludedByParent_MustRe /// /// Tests equals. /// - [Fact] + [Test] public void Equals_DifferentInstancesNotSameAttributesButExcludedBySubCompareExclusion_MustReturnTrue() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs b/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs index a08514a..47a6c00 100644 --- a/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs @@ -7,9 +7,9 @@ using BBT.StructureTools.Tests.Compare.Intention; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class ToManyComparerTests { #region Members, Setup @@ -17,12 +17,12 @@ public class ToManyComparerTests public ToManyComparerTests() { - var kernel = TestIoContainer.Initialize(); + var iocContainer = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); + iocContainer.RegisterSingleton, TestClassCompareRegistrations>(); + iocContainer.RegisterSingleton, TestClassListOfChildrenItemCompareRegistrations>(); - this.comparer = kernel.Get>(); + this.comparer = iocContainer.GetInstance>(); } #endregion @@ -30,17 +30,17 @@ public ToManyComparerTests() /// /// Tests the compare infrastructure. /// - [Fact] + [Test] public void Compare_SameInstance_MustReturnTrue() { // Arrange var testClass = new TestClass() { ListOfChildren = - new List + new List { - new TestClassistOfChildrenItem(), - new TestClassistOfChildrenItem(), + new TestClassListOfChildrenItem(), + new TestClassListOfChildrenItem(), }, }; @@ -54,7 +54,7 @@ public void Compare_SameInstance_MustReturnTrue() /// /// Tests the compare infrastructure. /// - [Fact] + [Test] public void Compare_SameInstanceButistNull_MustReturnTrue() { // Arrange @@ -74,15 +74,15 @@ public void Compare_SameInstanceButistNull_MustReturnTrue() /// /// Tests the compare infrastructure. /// - [Fact] + [Test] public void Compare_DifferentInstancesSameist_MustReturnTrue() { // Arrange var listOfChildren = - new List + new List { - new TestClassistOfChildrenItem { TestValue1 = 1 }, - new TestClassistOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, }; var testClass = new TestClass() @@ -107,27 +107,27 @@ public void Compare_DifferentInstancesSameist_MustReturnTrue() /// /// Tests the compare infrastructure. /// - [Fact] + [Test] public void Compare_DifferentInstancesDifferentistsSameValues_MustReturnTrue() { // Arrange var testClass = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 1 }, - new TestClassistOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, }, }; var testClass2 = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 1 }, - new TestClassistOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, }, }; @@ -141,27 +141,27 @@ public void Compare_DifferentInstancesDifferentistsSameValues_MustReturnTrue() /// /// Tests the compare infrastructure. /// - [Fact] + [Test] public void Compare_DifferentInstancesDifferentistsSameValuesDifferentistPositions_MustReturnTrue() { // Arrange var testClass = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 1 }, - new TestClassistOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, }, }; var testClass2 = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 2 }, - new TestClassistOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, }, }; @@ -175,27 +175,27 @@ public void Compare_DifferentInstancesDifferentistsSameValuesDifferentistPositio /// /// Tests the compare infrastructure. /// - [Fact] + [Test] public void Compare_DifferentInstancesDifferentistsDifferentValues_MustReturnFalse() { // Arrange var testClass = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 1 }, - new TestClassistOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 1 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, }, }; var testClass2 = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 2 }, - new TestClassistOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, }, }; @@ -209,26 +209,26 @@ public void Compare_DifferentInstancesDifferentistsDifferentValues_MustReturnFal /// /// Tests the compare infrastructure. /// - [Fact] + [Test] public void Compare_DifferentInstancesDifferentistsDifferentValuesDifferentistCounts_MustReturnFalse() { // Arrange var testClass = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, }, }; var testClass2 = new TestClass() { // Explicitly set to different ist instance - ListOfChildren = new List + ListOfChildren = new List { - new TestClassistOfChildrenItem { TestValue1 = 2 }, - new TestClassistOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, + new TestClassListOfChildrenItem { TestValue1 = 2 }, }, }; @@ -243,15 +243,15 @@ public void Compare_DifferentInstancesDifferentistsDifferentValuesDifferentistCo private class TestClass { - public List ListOfChildren { private get; set; } + public List ListOfChildren { private get; set; } - public List GetChildren() + public List GetChildren() { return this.ListOfChildren; } } - private class TestClassistOfChildrenItem + private class TestClassListOfChildrenItem { public int TestValue1 { get; set; } @@ -266,13 +266,13 @@ public void DoRegistrations(IEqualityComparerHelperRegistration regis registrations.RegisterToManyRelationship( x => x.GetChildren(), - IocHandler.Instance.IocResolver.GetInstance>()); + IocHandler.Instance.IocResolver.GetInstance>()); } } - private class TestClassistOfChildrenItecompareRegistrations : ICompareRegistrations + private class TestClassListOfChildrenItemCompareRegistrations : ICompareRegistrations { - public void DoRegistrations(IEqualityComparerHelperRegistration registrations) + public void DoRegistrations(IEqualityComparerHelperRegistration registrations) { registrations.Should().NotBeNull(); diff --git a/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs b/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs index a416c95..13dbe7b 100644 --- a/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs @@ -5,11 +5,11 @@ using BBT.StructureTools.Tests.Convert.TestStructure.Source; using BBT.StructureTools.Tests.Convert.TestStructure.Target; using Moq; - using Xunit; + using NUnit.Framework; public class ConvertHelperTests { - [Fact] + [Test] public void PreProcessing_WithEmptyist_Succeeds() { var testcandidate = new ConvertHelper(); @@ -21,7 +21,7 @@ public void PreProcessing_WithEmptyist_Succeeds() testcandidate.DoConvertPreProcessing(source, target, preprocessings); } - [Fact] + [Test] public void PreProcessing_ExecutesPreprocessing() { var testcandidate = new ConvertHelper(); @@ -51,7 +51,7 @@ public void PreProcessing_ExecutesPreprocessing() preprocShouldNotExecuteBecauseWrongProcessingType.Verify(x => x.DoPostProcessing(source, target), Times.Never); } - [Fact] + [Test] public void PostProcessing_WithEmptyist_Succeeds() { var testcandidate = new ConvertHelper(); @@ -63,7 +63,7 @@ public void PostProcessing_WithEmptyist_Succeeds() testcandidate.DoConvertPostProcessing(source, target, preprocessings); } - [Fact] + [Test] public void PostProcessing_ExecutesPostprocessing() { var testcandidate = new ConvertHelper(); @@ -93,7 +93,7 @@ public void PostProcessing_ExecutesPostprocessing() postprocShouldNotExecuteBecauseWrongProcessingType.Verify(x => x.DoPreProcessing(source, target), Times.Never); } - [Fact] + [Test] public void Intercept_WithEmptyist_Succeeds() { var testcandidate = new ConvertHelper(); @@ -104,7 +104,7 @@ public void Intercept_WithEmptyist_Succeeds() testcandidate.ContinueConvertProcess(source, preprocessings); } - [Fact] + [Test] public void ConvertInterception_Intercepts() { var testcandidate = new ConvertHelper(); diff --git a/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs b/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs index 5f9f4b8..20d728d 100644 --- a/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs @@ -12,34 +12,34 @@ using BBT.StructureTools.Tests.Convert.TestStructure.Target; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class ConvertRootTreeLeafWithMasterDataTests { private readonly IConvert testcandidate; public ConvertRootTreeLeafWithMasterDataTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind(typeof(ITemporalDataDescriptor<>)).To(); + kernel.RegisterSingleton(typeof(ITemporalDataDescriptor<>), typeof(TemporalDataDescriptor)); - kernel.Bind>().To(); + kernel.RegisterSingleton, RootTargetRootConvertRegistrations>(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TreeTargetTreeConvertRegistrations>(); + kernel.RegisterSingleton, TreeMasterDataToTreeConvertRegistrations>(); - kernel.Bind>().To(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, LeafTargetLeafConvertRegistrations>(); + kernel.RegisterSingleton, LeafMasterDataTargetLeafConvertRegistrations>(); + kernel.RegisterSingleton, TemporalLeafMasterDataTemporalLeafDatconvertRegistrations>(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TemporalDatcopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } - [Fact] + [Test] public void StructureFromRootToLeafIsConvertIntoTargetStructure() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs b/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs index cce9768..fb6bd55 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs @@ -8,9 +8,9 @@ using BBT.StructureTools.Copy.Processing; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopierIntegrationTests { #region members and setup @@ -18,13 +18,13 @@ public class CopierIntegrationTests public CopierIntegrationTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); + kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); + kernel.RegisterSingleton, ChildTestClass2CopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -32,7 +32,7 @@ public CopierIntegrationTests() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustNotCopyChildrenWhenIntercepted() { // Arrange @@ -73,7 +73,7 @@ public void Copy_MustNotCopyChildrenWhenIntercepted() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustCopyInheritedChildrenWhenIntercepted() { // Arrange @@ -119,7 +119,7 @@ public void Copy_MustCopyInheritedChildrenWhenIntercepted() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustNotCopyInheritedChildrenAndChildrenWhenChildrenIntercepted() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs index 41e5c79..a7559eb 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs @@ -2,7 +2,6 @@ { using System; using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using System.Linq; using BBT.StrategyPattern; using BBT.StructureTools.Copy; @@ -10,9 +9,9 @@ using BBT.StructureTools.Copy.Strategy; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationCreateToManyFromGenericStrategyIntTests { #region setup @@ -21,14 +20,14 @@ public class CopyOperationCreateToManyFromGenericStrategyIntTests public CopyOperationCreateToManyFromGenericStrategyIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); - kernel.Bind>().To(); - kernel.Bind().To(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); + kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); + kernel.RegisterSingleton, TestFactory>(); + kernel.RegisterSingleton(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -36,7 +35,7 @@ public CopyOperationCreateToManyFromGenericStrategyIntTests() /// /// Tests whether the strategy is actually being used during copy. /// - [Fact] + [Test] public void MustUseStrategyWhenCopying() { // Arrange @@ -78,7 +77,7 @@ public void MustUseStrategyWhenCopying() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustFailWhenChildrenistNull() { // Arrange @@ -98,7 +97,7 @@ public void Copy_MustFailWhenChildrenistNull() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustCopyEmptyCollection() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs index 541a4ac..5012b7e 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs @@ -9,9 +9,9 @@ using BBT.StructureTools.Copy.Strategy; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests { #region setup @@ -20,14 +20,14 @@ public class CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntT public CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind().To(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestFactory>(); + kernel.RegisterSingleton(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); + kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -35,7 +35,7 @@ public CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests() /// /// Tests whether the strategy is actually being used during copy. /// - [Fact] + [Test] public void MustUseStrategyWhenCopying() { // Arrange @@ -83,7 +83,7 @@ public void MustUseStrategyWhenCopying() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustFailWhenChildrenistNull() { // Arrange @@ -103,7 +103,7 @@ public void Copy_MustFailWhenChildrenistNull() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustCopyEmptyCollection() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs index cba7dfb..a9ddc4a 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs @@ -8,10 +8,9 @@ using BBT.StructureTools.Copy.Helper; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; - using Xunit.Sdk; + using NUnit.Framework; + [TestFixture] public class CopyOperationCreateToManyWithReverseRelationIntTests { #region members and setup @@ -19,12 +18,12 @@ public class CopyOperationCreateToManyWithReverseRelationIntTests public CopyOperationCreateToManyWithReverseRelationIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); + kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -32,7 +31,7 @@ public CopyOperationCreateToManyWithReverseRelationIntTests() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustCopyParentReference() { // Arrange @@ -77,7 +76,7 @@ public void Copy_MustCopyParentReference() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustFailWhenChildrenistNull() { // Arrange @@ -87,9 +86,9 @@ public void Copy_MustFailWhenChildrenistNull() var testClassParentCopy = new ParentTestClass(); // Act / Assert throws - // This exception is not originating from XUnit per se, + // This exception is not originating from NUnit.Framework per se, // but from the assertion library which is itself using - // Xunit internally. + // NUnit.Framework internally. Assert.Throws(() => this.testcandidate.Copy( testClassParentOriginal, @@ -100,7 +99,7 @@ public void Copy_MustFailWhenChildrenistNull() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustCopyEmptyCollection() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs index 371eb0b..17e4375 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs @@ -2,15 +2,14 @@ { using System; using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using BBT.StructureTools; using BBT.StructureTools.Copy; using BBT.StructureTools.Copy.Helper; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationCreateToOneWithReverseRelationIntTests { #region members and setup @@ -18,12 +17,12 @@ public class CopyOperationCreateToOneWithReverseRelationIntTests public CopyOperationCreateToOneWithReverseRelationIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); + kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -31,7 +30,7 @@ public CopyOperationCreateToOneWithReverseRelationIntTests() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustCopyParentReference() { // Arrange @@ -61,7 +60,7 @@ public void Copy_MustCopyParentReference() /// Tests if the infrastructure can handle a copy create to one with reverse relation /// where the child is null. /// - [Fact] + [Test] public void Copy_MustNotFailWhenChildIsNull() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs index bfefd20..cc741b5 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs @@ -6,28 +6,28 @@ using BBT.StructureTools.Copy.Helper; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationCrossReferenceProcessingIntTests { private readonly ICopy testcandidate; public CopyOperationCrossReferenceProcessingIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); + kernel.RegisterSingleton, TestClassChildCopyRegistrations>(); + kernel.RegisterSingleton, TestClassCrossReferencedChildCopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void MustExecuteAndSetCrossReferenceRegistrations() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs index fe7db66..75018c6 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs @@ -7,26 +7,26 @@ using BBT.StructureTools.Copy.Helper; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationInlineValueProcessingTests { private readonly ICopy testcandidate; public CopyOperationInlineValueProcessingTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void MustExecuteInlineCopyProcessing() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs index fcd515e..6ac8bb7 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs @@ -7,26 +7,26 @@ using BBT.StructureTools.Copy.Processing; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationIntTests { private readonly ICopy testcandidate; public CopyOperationIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassCopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_WhenAttributeRegistered_MustCopyAttribute() { // Arrange @@ -43,7 +43,7 @@ public void Copy_WhenAttributeRegistered_MustCopyAttribute() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_WhenAttributeNotRegistered_MustNotCopyAttribute() { // Arrange @@ -60,7 +60,7 @@ public void Copy_WhenAttributeNotRegistered_MustNotCopyAttribute() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustExecuteAdditionalProcessings() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs index 735bbf1..65e29ca 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs @@ -6,27 +6,27 @@ using BBT.StructureTools.Copy.Helper; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationRegisterCreateFromFactoryTests { private readonly ICopy testcandidate; public CopyOperationRegisterCreateFromFactoryTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind().To(); + kernel.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); + kernel.RegisterSingleton(typeof(ITestFactory), typeof(TestFactory)); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void MustExecuteInlineCopyProcessing() { // Arrange @@ -42,7 +42,7 @@ public void MustExecuteInlineCopyProcessing() } /// - /// An interface defining a factory for test values - Used with RegisterInlineIocFactoryProcessing. + /// An interface defining a Factory for test values - Used with RegisterInlineIocFactoryProcessing. /// private interface ITestFactory { diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs index 4ede30e..fb9444c 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs @@ -7,27 +7,27 @@ using BBT.StructureTools.Copy.Processing; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationSubCopyIntTests { private readonly ICopy testcandidate; public CopyOperationSubCopyIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); - kernel.Bind>().To(); + kernel.RegisterSingleton, TestClassChildCopyRegistrations>(); + kernel.RegisterSingleton, TestClassParentCopyRegistrations>(); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_WhenAttributeRegistered_MustCopyAttribute() { // Arrange @@ -44,7 +44,7 @@ public void Copy_WhenAttributeRegistered_MustCopyAttribute() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_WhenAttributeNotRegistered_MustNotCopyAttribute() { // Arrange @@ -61,7 +61,7 @@ public void Copy_WhenAttributeNotRegistered_MustNotCopyAttribute() /// /// Tests ICopy.Copy. /// - [Fact] + [Test] public void Copy_MustExecuteAdditionalProcessings() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs index cb845b3..63a3d3d 100644 --- a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs @@ -6,9 +6,9 @@ using BBT.StructureTools.Copy.Processing; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public sealed class CopyOperationPostProcessingUsingParamsIntTests { #region setup and members @@ -17,11 +17,11 @@ public sealed class CopyOperationPostProcessingUsingParamsIntTests public CopyOperationPostProcessingUsingParamsIntTests() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); + kernel.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -32,7 +32,7 @@ public CopyOperationPostProcessingUsingParamsIntTests() /// Tests for the execution of a single post processing which was registered via /// Copy Registrations. /// - [Fact] + [Test] public void MustExecuteRegisteredPostProcessingsWhenParamsAreUsed() { // Arrange diff --git a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs index 6bec946..ca2181a 100644 --- a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs +++ b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs @@ -6,9 +6,9 @@ using BBT.StructureTools.Copy.Processing; using BBT.StructureTools.Tests.TestTools; using FluentAssertions; - using Ninject; - using Xunit; + using NUnit.Framework; + [TestFixture] public class CopyOperationPostProcessingWithoutUsingParamsIntTest { #region setup and members @@ -17,11 +17,11 @@ public class CopyOperationPostProcessingWithoutUsingParamsIntTest public CopyOperationPostProcessingWithoutUsingParamsIntTest() { - var kernel = TestIoContainer.Initialize(); + var kernel = new NinjectIocContainer(); - kernel.Bind>().To(); + kernel.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); - this.testcandidate = kernel.Get>(); + this.testcandidate = kernel.GetInstance>(); } #endregion @@ -32,7 +32,7 @@ public CopyOperationPostProcessingWithoutUsingParamsIntTest() /// Tests for the execution of a single post processing which was registered via /// Copy Registrations. /// - [Fact] + [Test] public void MustExecuteRegisteredSinglePostProcessings() { // Arrange diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs new file mode 100644 index 0000000..bbcdb6e --- /dev/null +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs @@ -0,0 +1,47 @@ +namespace BBT.StructureTools.Tests.TestTools.IoC +{ + using System; + + /// + /// Abstraction of any IoC container to be used for testing. + /// + internal interface IIocContainer + { + /// + /// Initializes the IoC container. + /// + void Initialize(); + + /// + /// Registers the for the given + /// as singleton instance. + /// + /// Abstraction (interface) type. + /// Implementation of . + void RegisterSingleton() + where TImplementation : TAbstraction; + + /// + /// Registers the for the given + /// transiently. + /// + /// Abstraction (interface) type. + /// Implementation of . + void RegisterTransient() + where TImplementation : TAbstraction; + + /// + /// Registers the for the given + /// as singleton instance. + /// + /// Abstraction (interface) type. + /// Implementation of the abstraction. + void RegisterSingleton(Type abstraction, Type implementation); + + /// + /// Returns the implementation registered for . + /// + /// Abstraction for which the implementation is returned. + T GetInstance(); + } +} diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectIocContainer.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectIocContainer.cs new file mode 100644 index 0000000..5deb802 --- /dev/null +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectIocContainer.cs @@ -0,0 +1,68 @@ +namespace BBT.StructureTools.Tests.TestTools +{ + using System; + using BBT.StrategyPattern; + using BBT.StructureTools.Initialization; + using BBT.StructureTools.Tests.TestTools.IoC; + using Ninject; + + /// + internal class NinjectIocContainer : IIocContainer + { + private StandardKernel ninjectKernel; + + /// + /// Initializes a new instance of the class. + /// + public NinjectIocContainer() + { + this.Initialize(); + } + + /// + public T GetInstance() + { + return this.ninjectKernel.Get(); + } + + /// + public void Initialize() + { + var settings = new NinjectSettings + { + InjectNonPublic = true, + }; + + this.ninjectKernel = new StandardKernel(settings); + + var resolver = new NinjectResolver(this.ninjectKernel); + IocHandler.Instance.IocResolver = resolver; + + // Dependencies from BBT.StrategyPattern + this.ninjectKernel.Bind(typeof(IStrategyLocator<>)).To(typeof(NinjectStrategyLocator<>)); + this.ninjectKernel.Bind(typeof(IInstanceCreator<,>)).To(typeof(GenericInstanceCreator<,>)); + + IocHandler.Instance.DoIocRegistrations(this.RegisterSingleton); + } + + /// + public void RegisterSingleton() + where TImplementation : TAbstraction + { + this.ninjectKernel.Bind().To().InSingletonScope(); + } + + /// + public void RegisterTransient() + where TImplementation : TAbstraction + { + this.ninjectKernel.Bind().To().InTransientScope(); + } + + /// + public void RegisterSingleton(Type abstraction, Type implementation) + { + this.ninjectKernel.Bind(abstraction).To(implementation).InSingletonScope(); + } + } +} diff --git a/src/BBT.StructureTools.Tests/TestTools/TestIoContainer.cs b/src/BBT.StructureTools.Tests/TestTools/TestIoContainer.cs deleted file mode 100644 index e016237..0000000 --- a/src/BBT.StructureTools.Tests/TestTools/TestIoContainer.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace BBT.StructureTools.Tests.TestTools -{ - using System; - using BBT.StrategyPattern; - using BBT.StructureTools.Compare; - using BBT.StructureTools.Compare.Helper; - using BBT.StructureTools.Convert; - using BBT.StructureTools.Convert.Strategy; - using BBT.StructureTools.Convert.Value; - using BBT.StructureTools.Copy; - using BBT.StructureTools.Copy.Helper; - using BBT.StructureTools.Copy.Operation; - using BBT.StructureTools.Copy.Strategy; - using BBT.StructureTools.Initialization; - using BBT.StructureTools.Tests.TestTools.IoC; - using Ninject; - - /// - /// Utilities to set up and configure for test runs. - /// - /// - /// Keep this code testframework-agnostic!. - /// - public static class TestIoContainer - { - /// - /// Register types for copy, convert, and compare with - /// Ninject and create a resolver which is assigned to the - /// . The - /// which is used within the is being - /// returned for further manipulation from within the calling test or test setup method. - /// - public static IKernel Initialize() - { - var settings = new NinjectSettings - { - InjectNonPublic = true, - }; - - var kernel = new StandardKernel(settings); - - var resolver = new NinjectResolver(kernel); - IocHandler.Instance.IocResolver = resolver; - - // Dependencies from BBT.StrategyPattern - kernel.Bind(typeof(IStrategyLocator<>)).To(typeof(NinjectStrategyLocator<>)); - kernel.Bind(typeof(IInstanceCreator<,>)).To(typeof(GenericInstanceCreator<,>)); - - IocHandler.Instance.DoIocRegistrations( - (Type abstraction, Type implementation) => - kernel.Bind(abstraction).To(implementation)); - - return kernel; - } - } -} From ffda0e37ece1128168ad6e99b4fd2564a0a7a91f Mon Sep 17 00:00:00 2001 From: Marco Bertschi Date: Wed, 27 Nov 2019 16:09:58 +0100 Subject: [PATCH 2/2] Add tests for Castle Windsor --- .../BBT.StructureTools.Tests.csproj | 1 + .../ComparerWithObjectAttributeTests.cs | 11 ++-- ...ributeWithDistinguishedComparerIntTests.cs | 15 ++--- ...parerWithObjectsAndValueAttributesTests.cs | 12 ++-- .../ComparerWithValueAttributeTests.cs | 11 ++-- .../Compare/SubComparerUsingComparerTests.cs | 15 ++--- .../Compare/ToManyComparerTests.cs | 7 ++- .../Convert/ConvertHelperTests.cs | 1 + .../ConvertRootTreeLeafWithMasterDataTests.cs | 25 ++++---- .../Copy/CopierIntegrationTests.cs | 15 ++--- ...CreateToManyFromGenericStrategyIntTests.cs | 17 +++--- ...ericStrategyWithReverseRelationIntTests.cs | 17 +++--- ...CreateToManyWithReverseRelationIntTests.cs | 13 +++-- ...nCreateToOneWithReverseRelationIntTests.cs | 13 +++-- ...erationCrossReferenceProcessingIntTests.cs | 15 ++--- ...CopyOperationInlineValueProcessingTests.cs | 11 ++-- .../Copy/CopyOperationIntTests.cs | 11 ++-- ...OperationRegisterCreateFromFactoryTests.cs | 13 +++-- .../Copy/CopyOperationSubCopyIntTests.cs | 13 +++-- ...rationPostProcessingUsingParamsIntTests.cs | 11 ++-- ...PostProcessingWithoutUsingParamsIntTest.cs | 11 ++-- .../TestTools/IoC/IIocContainer.cs | 4 +- ...ocator.cs => IocHandlerStrategyLocator.cs} | 2 +- .../TestTools/IoC/IocTestFixtureSource.cs | 24 ++++++++ .../IoC/Vendor/CastleIocContainer.cs | 58 +++++++++++++++++++ .../TestTools/IoC/Vendor/CastleResolver.cs | 41 +++++++++++++ .../IoC/{ => Vendor}/NinjectIocContainer.cs | 14 ++--- .../IoC/{ => Vendor}/NinjectResolver.cs | 2 +- .../Compare/CompareHelper.cs | 2 +- src/BBT.StructureTools/Compare/Comparer.cs | 2 +- src/BBT.StructureTools/Convert/Converter.cs | 2 +- .../Convert/IConvertEngine.cs | 2 +- .../Convert/IConvertHelper.cs | 2 +- .../Strategy/OperationCopyValueWithLookup.cs | 1 - .../Copy/Helper/CopyHelperFactory.cs | 1 - .../Copy/Helper/CreateCopyHelper.cs | 1 - .../Copy/Helper/ICopyHelperRegistration.cs | 1 - ...perationCreateToManyWithReverseRelation.cs | 1 - .../Extension/BitOperations.cs | 2 - 39 files changed, 278 insertions(+), 142 deletions(-) rename src/BBT.StructureTools.Tests/TestTools/IoC/{NinjectStrategyLocator.cs => IocHandlerStrategyLocator.cs} (80%) create mode 100644 src/BBT.StructureTools.Tests/TestTools/IoC/IocTestFixtureSource.cs create mode 100644 src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleIocContainer.cs create mode 100644 src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleResolver.cs rename src/BBT.StructureTools.Tests/TestTools/IoC/{ => Vendor}/NinjectIocContainer.cs (85%) rename src/BBT.StructureTools.Tests/TestTools/IoC/{ => Vendor}/NinjectResolver.cs (93%) diff --git a/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj b/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj index 5ab6eb0..0b62d00 100644 --- a/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj +++ b/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj @@ -23,6 +23,7 @@ + diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs index 194e793..fb9cc93 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeTests.cs @@ -5,7 +5,7 @@ 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; @@ -13,18 +13,19 @@ /// Test for Comparer infrastructure with object attributes. /// [TestFixture] + [TestFixtureSource(typeof(IocTestFixtureSource), "IocContainers")] public class ComparerWithObjectAttributeTests { #region Members, Setup private readonly IComparer testcandidate; - public ComparerWithObjectAttributeTests() + public ComparerWithObjectAttributeTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCompareRegistrations>(); + iocContainer.RegisterSingleton, TestClassCompareRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs index c9fbd1d..97e432e 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectAttributeWithDistinguishedComparerIntTests.cs @@ -6,11 +6,12 @@ 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 @@ -18,15 +19,15 @@ public class ComparerWithObjectAttributeWithDistinguishedComparerIntTests private static IComparer distinguishedComparer; private readonly IComparer testcandidate; - public ComparerWithObjectAttributeWithDistinguishedComparerIntTests() + public ComparerWithObjectAttributeWithDistinguishedComparerIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCompareRegistrations>(); - kernel.RegisterSingleton, TestAttributeCompareRegistrations>(); + iocContainer.RegisterSingleton, TestClassCompareRegistrations>(); + iocContainer.RegisterSingleton, TestAttributeCompareRegistrations>(); - distinguishedComparer = kernel.GetInstance>(); - this.testcandidate = kernel.GetInstance>(); + distinguishedComparer = iocContainer.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs index 8e120e4..09b1c1e 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithObjectsAndValueAttributesTests.cs @@ -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 testcandidate; - public ComparerWithObjectsAndValueAttributesTests() + public ComparerWithObjectsAndValueAttributesTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); - kernel.RegisterSingleton, TestClassCompareRegistrations>(); + iocContainer.Initialize(); - this.testcandidate = kernel.GetInstance>(); + iocContainer.RegisterSingleton, TestClassCompareRegistrations>(); + + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs b/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs index 36f3284..cc282ee 100644 --- a/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ComparerWithValueAttributeTests.cs @@ -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 testcandidate; - public ComparerWithValueAttributeTests() + public ComparerWithValueAttributeTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCompareRegistrations>(); + iocContainer.RegisterSingleton, TestClassCompareRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } [Test] diff --git a/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs b/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs index 61dc2a9..82eed6b 100644 --- a/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/SubComparerUsingComparerTests.cs @@ -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 parentCompare; private readonly IComparer testcandidate; - public SubComparerUsingComparerTests() + public SubComparerUsingComparerTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassChildCompareRegistrations>(); - kernel.RegisterSingleton, TestClassParentCompareRegistrations>(); + iocContainer.RegisterSingleton, TestClassChildCompareRegistrations>(); + iocContainer.RegisterSingleton, TestClassParentCompareRegistrations>(); - parentCompare = kernel.GetInstance>(); - this.testcandidate = kernel.GetInstance>(); + parentCompare = iocContainer.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs b/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs index 47a6c00..20c921b 100644 --- a/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs +++ b/src/BBT.StructureTools.Tests/Compare/ToManyComparerTests.cs @@ -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 comparer; - public ToManyComparerTests() + public ToManyComparerTests(IIocContainer iocContainer) { - var iocContainer = new NinjectIocContainer(); + iocContainer.Initialize(); iocContainer.RegisterSingleton, TestClassCompareRegistrations>(); iocContainer.RegisterSingleton, TestClassListOfChildrenItemCompareRegistrations>(); diff --git a/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs b/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs index 13dbe7b..d2979e9 100644 --- a/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/ConvertHelperTests.cs @@ -7,6 +7,7 @@ using Moq; using NUnit.Framework; + [TestFixture] public class ConvertHelperTests { [Test] diff --git a/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs b/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs index 20d728d..87b7925 100644 --- a/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/ConvertRootTreeLeafWithMasterDataTests.cs @@ -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 testcandidate; - public ConvertRootTreeLeafWithMasterDataTests() + public ConvertRootTreeLeafWithMasterDataTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton(typeof(ITemporalDataDescriptor<>), typeof(TemporalDataDescriptor)); + iocContainer.RegisterSingleton(typeof(ITemporalDataDescriptor), typeof(TemporalDataDescriptor)); - kernel.RegisterSingleton, RootTargetRootConvertRegistrations>(); + iocContainer.RegisterSingleton, RootTargetRootConvertRegistrations>(); - kernel.RegisterSingleton, TreeTargetTreeConvertRegistrations>(); - kernel.RegisterSingleton, TreeMasterDataToTreeConvertRegistrations>(); + iocContainer.RegisterSingleton, TreeTargetTreeConvertRegistrations>(); + iocContainer.RegisterSingleton, TreeMasterDataToTreeConvertRegistrations>(); - kernel.RegisterSingleton, LeafTargetLeafConvertRegistrations>(); - kernel.RegisterSingleton, LeafMasterDataTargetLeafConvertRegistrations>(); - kernel.RegisterSingleton, TemporalLeafMasterDataTemporalLeafDatconvertRegistrations>(); + iocContainer.RegisterSingleton, LeafTargetLeafConvertRegistrations>(); + iocContainer.RegisterSingleton, LeafMasterDataTargetLeafConvertRegistrations>(); + iocContainer.RegisterSingleton, TemporalLeafMasterDataTemporalLeafDatconvertRegistrations>(); - kernel.RegisterSingleton, TemporalDatcopyRegistrations>(); + iocContainer.RegisterSingleton, TemporalDatcopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } [Test] diff --git a/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs b/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs index fb6bd55..6a447f3 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopierIntegrationTests.cs @@ -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 testcandidate; - public CopierIntegrationTests() + public CopierIntegrationTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); - kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); - kernel.RegisterSingleton, ChildTestClass2CopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, ChildTestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, ChildTestClass2CopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs index a7559eb..97e4c81 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyIntTests.cs @@ -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 testcandidate; - public CopyOperationCreateToManyFromGenericStrategyIntTests() + public CopyOperationCreateToManyFromGenericStrategyIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); - kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); - kernel.RegisterSingleton, TestFactory>(); - kernel.RegisterSingleton(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, ChildTestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, TestFactory>(); + iocContainer.RegisterSingleton(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs index 5012b7e..a954d41 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests.cs @@ -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 testcandidate; - public CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests() + public CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestFactory>(); - kernel.RegisterSingleton(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); - kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, TestFactory>(); + iocContainer.RegisterSingleton(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, ChildTestClassCopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs index a9ddc4a..a024601 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToManyWithReverseRelationIntTests.cs @@ -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 testcandidate; - public CopyOperationCreateToManyWithReverseRelationIntTests() + public CopyOperationCreateToManyWithReverseRelationIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); - kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, ChildTestClassCopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs index 17e4375..c50672b 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCreateToOneWithReverseRelationIntTests.cs @@ -5,24 +5,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 CopyOperationCreateToOneWithReverseRelationIntTests { #region members and setup private readonly ICopy testcandidate; - public CopyOperationCreateToOneWithReverseRelationIntTests() + public CopyOperationCreateToOneWithReverseRelationIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); - kernel.RegisterSingleton, ChildTestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, ChildTestClassCopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs index cc741b5..6dd8850 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationCrossReferenceProcessingIntTests.cs @@ -4,24 +4,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 CopyOperationCrossReferenceProcessingIntTests { private readonly ICopy testcandidate; - public CopyOperationCrossReferenceProcessingIntTests() + public CopyOperationCrossReferenceProcessingIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); - kernel.RegisterSingleton, TestClassChildCopyRegistrations>(); - kernel.RegisterSingleton, TestClassCrossReferencedChildCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassChildCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassCrossReferencedChildCopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } /// diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs index 75018c6..f2b42e6 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationInlineValueProcessingTests.cs @@ -5,22 +5,23 @@ 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 CopyOperationInlineValueProcessingTests { private readonly ICopy testcandidate; - public CopyOperationInlineValueProcessingTests() + public CopyOperationInlineValueProcessingTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } /// diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs index 6ac8bb7..5f0a20a 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationIntTests.cs @@ -5,22 +5,23 @@ 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 CopyOperationIntTests { private readonly ICopy testcandidate; - public CopyOperationIntTests() + public CopyOperationIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassCopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } /// diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs index 65e29ca..58a5eb9 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationRegisterCreateFromFactoryTests.cs @@ -4,23 +4,24 @@ 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 CopyOperationRegisterCreateFromFactoryTests { private readonly ICopy testcandidate; - public CopyOperationRegisterCreateFromFactoryTests() + public CopyOperationRegisterCreateFromFactoryTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); - kernel.RegisterSingleton(typeof(ITestFactory), typeof(TestFactory)); + iocContainer.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); + iocContainer.RegisterSingleton(typeof(ITestFactory), typeof(TestFactory)); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } /// diff --git a/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs b/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs index fb9444c..9848c18 100644 --- a/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/CopyOperationSubCopyIntTests.cs @@ -5,23 +5,24 @@ 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 CopyOperationSubCopyIntTests { private readonly ICopy testcandidate; - public CopyOperationSubCopyIntTests() + public CopyOperationSubCopyIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton, TestClassChildCopyRegistrations>(); - kernel.RegisterSingleton, TestClassParentCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassChildCopyRegistrations>(); + iocContainer.RegisterSingleton, TestClassParentCopyRegistrations>(); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } /// diff --git a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs index 63a3d3d..204a3c6 100644 --- a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs +++ b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingUsingParamsIntTests.cs @@ -4,24 +4,25 @@ 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 sealed class CopyOperationPostProcessingUsingParamsIntTests { #region setup and members private readonly ICopy testcandidate; - public CopyOperationPostProcessingUsingParamsIntTests() + public CopyOperationPostProcessingUsingParamsIntTests(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); + iocContainer.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs index ca2181a..8714864 100644 --- a/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs +++ b/src/BBT.StructureTools.Tests/Copy/PostProcessing/CopyOperationPostProcessingWithoutUsingParamsIntTest.cs @@ -4,24 +4,25 @@ 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 CopyOperationPostProcessingWithoutUsingParamsIntTest { #region setup and members private readonly ICopy testcandidate; - public CopyOperationPostProcessingWithoutUsingParamsIntTest() + public CopyOperationPostProcessingWithoutUsingParamsIntTest(IIocContainer iocContainer) { - var kernel = new NinjectIocContainer(); + iocContainer.Initialize(); - kernel.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); + iocContainer.RegisterSingleton(typeof(ICopyRegistrations), typeof(TestClassCopyRegistrations)); - this.testcandidate = kernel.GetInstance>(); + this.testcandidate = iocContainer.GetInstance>(); } #endregion diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs index bbcdb6e..b60a49f 100644 --- a/src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/IIocContainer.cs @@ -5,7 +5,7 @@ /// /// Abstraction of any IoC container to be used for testing. /// - internal interface IIocContainer + public interface IIocContainer { /// /// Initializes the IoC container. @@ -19,6 +19,7 @@ internal interface IIocContainer /// Abstraction (interface) type. /// Implementation of . void RegisterSingleton() + where TAbstraction : class where TImplementation : TAbstraction; /// @@ -28,6 +29,7 @@ void RegisterSingleton() /// Abstraction (interface) type. /// Implementation of . void RegisterTransient() + where TAbstraction : class where TImplementation : TAbstraction; /// diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectStrategyLocator.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/IocHandlerStrategyLocator.cs similarity index 80% rename from src/BBT.StructureTools.Tests/TestTools/IoC/NinjectStrategyLocator.cs rename to src/BBT.StructureTools.Tests/TestTools/IoC/IocHandlerStrategyLocator.cs index 4b6f5d8..8395d71 100644 --- a/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectStrategyLocator.cs +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/IocHandlerStrategyLocator.cs @@ -4,7 +4,7 @@ using BBT.StrategyPattern; using BBT.StructureTools.Initialization; - public class NinjectStrategyLocator : IStrategyLocator + public class IocHandlerStrategyLocator : IStrategyLocator { public IEnumerable GetAllStrategies() { diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/IocTestFixtureSource.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/IocTestFixtureSource.cs new file mode 100644 index 0000000..7e22e0e --- /dev/null +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/IocTestFixtureSource.cs @@ -0,0 +1,24 @@ +namespace BBT.StructureTools.Tests.TestTools.IoC +{ + using BBT.StructureTools.Tests.TestTools.IoC.Vendor; + + /// + /// Class is internally used to provide + /// different IoC containers to test fixtures where + /// needed. See also https://github.com/nunit/docs/wiki/TestFixtureSource-Attribute. + /// + internal class IocTestFixtureSource + { +#pragma warning disable SA1401 // Fields should be private + /// + /// Returns implementations + /// for the tested IoC containers. + /// + internal static object[] IocContainers = +#pragma warning restore SA1401 // Fields should be private + { + new NinjectIocContainer(), + new CastleIocContainer(), + }; + } +} diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleIocContainer.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleIocContainer.cs new file mode 100644 index 0000000..85ee56c --- /dev/null +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleIocContainer.cs @@ -0,0 +1,58 @@ +namespace BBT.StructureTools.Tests.TestTools.IoC.Vendor +{ + using System; + using BBT.StrategyPattern; + using BBT.StructureTools.Initialization; + using Castle.MicroKernel.Registration; + using Castle.Windsor; + + /// + internal class CastleIocContainer : IIocContainer + { + private IWindsorContainer castleContainer; + + /// + public T GetInstance() + { + return this.castleContainer.Resolve(); + } + + /// + public void Initialize() + { + this.castleContainer = new WindsorContainer(); + + var resolver = new CastleResolver(this.castleContainer); + + IocHandler.Instance.IocResolver = resolver; + + // Dependencies from BBT.StrategyPattern + this.castleContainer.Register(Component.For(typeof(IStrategyLocator<>)).ImplementedBy(typeof(IocHandlerStrategyLocator<>))); + this.castleContainer.Register(Component.For(typeof(IInstanceCreator<,>)).ImplementedBy(typeof(GenericInstanceCreator<,>))); + + IocHandler.Instance.DoIocRegistrations(this.RegisterSingleton); + } + + /// + public void RegisterSingleton() + where TAbstraction : class + where TImplementation : TAbstraction + { + this.castleContainer.Register(Component.For().ImplementedBy()); + } + + /// + public void RegisterTransient() + where TAbstraction : class + where TImplementation : TAbstraction + { + this.castleContainer.Register(Component.For().ImplementedBy().LifestyleTransient()); + } + + /// + public void RegisterSingleton(Type abstraction, Type implementation) + { + this.castleContainer.Register(Component.For(abstraction).ImplementedBy(implementation)); + } + } +} diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleResolver.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleResolver.cs new file mode 100644 index 0000000..0aae36c --- /dev/null +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/CastleResolver.cs @@ -0,0 +1,41 @@ +namespace BBT.StructureTools.Tests.TestTools.IoC.Vendor +{ + using System; + using System.Collections.Generic; + using BBT.StructureTools.Initialization; + using Castle.Windsor; + + /// + /// implementation for Castle Windsor. + /// + internal class CastleResolver : IIocResolver + { + private readonly IWindsorContainer windsorContainer; + + /// + /// Initializes a new instance of the class. + /// + public CastleResolver(IWindsorContainer windsorContainer) + { + this.windsorContainer = windsorContainer; + } + + /// + public IEnumerable GetAllInstances() + { + return this.windsorContainer.ResolveAll(); + } + + /// + public TService GetInstance() + { + return this.windsorContainer.Resolve(); + } + + /// + public object GetInstance(Type serviceType) + { + return this.windsorContainer.Resolve(serviceType); + } + } +} diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectIocContainer.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/NinjectIocContainer.cs similarity index 85% rename from src/BBT.StructureTools.Tests/TestTools/IoC/NinjectIocContainer.cs rename to src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/NinjectIocContainer.cs index 5deb802..5fb7495 100644 --- a/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectIocContainer.cs +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/NinjectIocContainer.cs @@ -1,4 +1,4 @@ -namespace BBT.StructureTools.Tests.TestTools +namespace BBT.StructureTools.Tests.TestTools.IoC.Vendor { using System; using BBT.StrategyPattern; @@ -11,14 +11,6 @@ internal class NinjectIocContainer : IIocContainer { private StandardKernel ninjectKernel; - /// - /// Initializes a new instance of the class. - /// - public NinjectIocContainer() - { - this.Initialize(); - } - /// public T GetInstance() { @@ -39,7 +31,7 @@ public void Initialize() IocHandler.Instance.IocResolver = resolver; // Dependencies from BBT.StrategyPattern - this.ninjectKernel.Bind(typeof(IStrategyLocator<>)).To(typeof(NinjectStrategyLocator<>)); + this.ninjectKernel.Bind(typeof(IStrategyLocator<>)).To(typeof(IocHandlerStrategyLocator<>)); this.ninjectKernel.Bind(typeof(IInstanceCreator<,>)).To(typeof(GenericInstanceCreator<,>)); IocHandler.Instance.DoIocRegistrations(this.RegisterSingleton); @@ -47,6 +39,7 @@ public void Initialize() /// public void RegisterSingleton() + where TAbstraction : class where TImplementation : TAbstraction { this.ninjectKernel.Bind().To().InSingletonScope(); @@ -54,6 +47,7 @@ public void RegisterSingleton() /// public void RegisterTransient() + where TAbstraction : class where TImplementation : TAbstraction { this.ninjectKernel.Bind().To().InTransientScope(); diff --git a/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectResolver.cs b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/NinjectResolver.cs similarity index 93% rename from src/BBT.StructureTools.Tests/TestTools/IoC/NinjectResolver.cs rename to src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/NinjectResolver.cs index 3ac06c8..a8d5507 100644 --- a/src/BBT.StructureTools.Tests/TestTools/IoC/NinjectResolver.cs +++ b/src/BBT.StructureTools.Tests/TestTools/IoC/Vendor/NinjectResolver.cs @@ -1,4 +1,4 @@ -namespace BBT.StructureTools.Tests.TestTools.IoC +namespace BBT.StructureTools.Tests.TestTools.IoC.Vendor { using System; using System.Collections.Generic; diff --git a/src/BBT.StructureTools/Compare/CompareHelper.cs b/src/BBT.StructureTools/Compare/CompareHelper.cs index b2dcb4f..51e780a 100644 --- a/src/BBT.StructureTools/Compare/CompareHelper.cs +++ b/src/BBT.StructureTools/Compare/CompareHelper.cs @@ -10,7 +10,7 @@ internal class CompareHelper : ICompareHelper /// /// Initializes a new instance of the class. /// - internal CompareHelper() + public CompareHelper() { } diff --git a/src/BBT.StructureTools/Compare/Comparer.cs b/src/BBT.StructureTools/Compare/Comparer.cs index 5add3f5..0f85227 100644 --- a/src/BBT.StructureTools/Compare/Comparer.cs +++ b/src/BBT.StructureTools/Compare/Comparer.cs @@ -16,7 +16,7 @@ internal class Comparer : IComparer /// /// Initializes a new instance of the class. /// - internal Comparer( + public Comparer( ICompareRegistrations compareRegistrations, IEqualityComparerHelperRegistrationFactory factory, ICompareHelper compareHelper) diff --git a/src/BBT.StructureTools/Convert/Converter.cs b/src/BBT.StructureTools/Convert/Converter.cs index 518f813..9b1d21f 100644 --- a/src/BBT.StructureTools/Convert/Converter.cs +++ b/src/BBT.StructureTools/Convert/Converter.cs @@ -15,7 +15,7 @@ public class Converter : IConvert /// Initializes a new instance of the class. /// - internal Converter( + public Converter( IConvertRegistrations convertRegistrations, IConvertEngine convertEngine, IConvertHelper convertHelper) diff --git a/src/BBT.StructureTools/Convert/IConvertEngine.cs b/src/BBT.StructureTools/Convert/IConvertEngine.cs index a310ea7..47c1bd6 100644 --- a/src/BBT.StructureTools/Convert/IConvertEngine.cs +++ b/src/BBT.StructureTools/Convert/IConvertEngine.cs @@ -5,7 +5,7 @@ /// /// The source to copy from. /// The target to copy to. - internal interface IConvertEngine + public interface IConvertEngine where TSource : class where TTarget : class { diff --git a/src/BBT.StructureTools/Convert/IConvertHelper.cs b/src/BBT.StructureTools/Convert/IConvertHelper.cs index a320651..5b712f6 100644 --- a/src/BBT.StructureTools/Convert/IConvertHelper.cs +++ b/src/BBT.StructureTools/Convert/IConvertHelper.cs @@ -5,7 +5,7 @@ /// /// Helper for the convert implementations. /// - internal interface IConvertHelper + public interface IConvertHelper { /// /// Start the convert pre process it it's needed. diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCopyValueWithLookup.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCopyValueWithLookup.cs index 76ceff6..7e4e31b 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCopyValueWithLookup.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCopyValueWithLookup.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; - using BBT.StructureTools.Convert.Strategy; using BBT.StructureTools.Extension; /// diff --git a/src/BBT.StructureTools/Copy/Helper/CopyHelperFactory.cs b/src/BBT.StructureTools/Copy/Helper/CopyHelperFactory.cs index c90985e..ddd731c 100644 --- a/src/BBT.StructureTools/Copy/Helper/CopyHelperFactory.cs +++ b/src/BBT.StructureTools/Copy/Helper/CopyHelperFactory.cs @@ -2,7 +2,6 @@ { using System; using System.Linq.Expressions; - using BBT.StructureTools.Convert; using BBT.StructureTools.Copy; using BBT.StructureTools.Extension; using BBT.StructureTools.Initialization; diff --git a/src/BBT.StructureTools/Copy/Helper/CreateCopyHelper.cs b/src/BBT.StructureTools/Copy/Helper/CreateCopyHelper.cs index 4b6526e..9bac3fc 100644 --- a/src/BBT.StructureTools/Copy/Helper/CreateCopyHelper.cs +++ b/src/BBT.StructureTools/Copy/Helper/CreateCopyHelper.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Linq.Expressions; using BBT.StrategyPattern; - using BBT.StructureTools.Convert; using BBT.StructureTools.Copy; using BBT.StructureTools.Copy.Processing; using BBT.StructureTools.Extension; diff --git a/src/BBT.StructureTools/Copy/Helper/ICopyHelperRegistration.cs b/src/BBT.StructureTools/Copy/Helper/ICopyHelperRegistration.cs index 502a535..0997137 100644 --- a/src/BBT.StructureTools/Copy/Helper/ICopyHelperRegistration.cs +++ b/src/BBT.StructureTools/Copy/Helper/ICopyHelperRegistration.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; - using BBT.StructureTools.Copy.Operation; using BBT.StructureTools.Copy.Strategy; /// diff --git a/src/BBT.StructureTools/Copy/Operation/CopyOperationCreateToManyWithReverseRelation.cs b/src/BBT.StructureTools/Copy/Operation/CopyOperationCreateToManyWithReverseRelation.cs index ce4b597..791e49f 100644 --- a/src/BBT.StructureTools/Copy/Operation/CopyOperationCreateToManyWithReverseRelation.cs +++ b/src/BBT.StructureTools/Copy/Operation/CopyOperationCreateToManyWithReverseRelation.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Linq.Expressions; using BBT.MaybePattern; - using BBT.StructureTools.Convert.Strategy; using BBT.StructureTools.Copy; using BBT.StructureTools.Extension; diff --git a/src/BBT.StructureTools/Extension/BitOperations.cs b/src/BBT.StructureTools/Extension/BitOperations.cs index ebdeed9..de78855 100644 --- a/src/BBT.StructureTools/Extension/BitOperations.cs +++ b/src/BBT.StructureTools/Extension/BitOperations.cs @@ -1,7 +1,5 @@ namespace BBT.StructureTools.Extension { - using System; - /// /// Helps with bit operations. ///