From 1d1874a3fe7743eddfe5654c74f755f2991d0376 Mon Sep 17 00:00:00 2001 From: Marco Bertschi Date: Wed, 27 Nov 2019 14:01:31 +0100 Subject: [PATCH] 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; - } - } -}