Skip to content

Commit

Permalink
Use NUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Bertschi committed Nov 27, 2019
1 parent d8cba7a commit 1d1874a
Show file tree
Hide file tree
Showing 25 changed files with 387 additions and 334 deletions.
3 changes: 0 additions & 3 deletions src/BBT.StructureTools.Tests/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)]
9 changes: 5 additions & 4 deletions src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<None Remove="Compare\ve-B655.tmp" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.9.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@
using BBT.StructureTools.Tests.Compare.Intention;
using BBT.StructureTools.Tests.TestTools;
using FluentAssertions;
using Ninject;
using Xunit;
using NUnit.Framework;

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

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

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

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

#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
Expand All @@ -46,7 +46,7 @@ public void Equals_WhenSameInstance_MustReturnTrue()
result.Should().BeTrue();
}

[Fact]
[Test]
public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue()
{
// Arrange
Expand All @@ -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 };

Expand All @@ -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 };

Expand All @@ -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 };

Expand All @@ -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<IComparerExclusion>
Expand All @@ -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
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@
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<TestAttribute, ITestCompareIntention> distinguishedComparer;
private static IComparer<TestWithProperties, ITestCompareIntention> distinguishedComparer;
private readonly IComparer<TestClass, ITestCompareIntention> testcandidate;

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

kernel.Bind<ICompareRegistrations<TestClass, ITestCompareIntention>>().To<TestClassCompareRegistrations>();
kernel.Bind<ICompareRegistrations<TestAttribute, ITestCompareIntention>>().To<TestAttributeCompareRegistrations>();
kernel.RegisterSingleton<ICompareRegistrations<TestClass, ITestCompareIntention>, TestClassCompareRegistrations>();
kernel.RegisterSingleton<ICompareRegistrations<TestWithProperties, ITestCompareIntention>, TestAttributeCompareRegistrations>();

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

#endregion

/// <summary>
/// Tests IComparer.Equals.
/// </summary>
[Fact]
[Test]
public void Equals_WhenSameInstance_MustReturnTrue()
{
// Arrange
var testClass = new TestClass
{
// Explicit instance init on purpose
TestAttribute = new TestAttribute(),
TestAttribute = new TestWithProperties(),
};

// Act
Expand All @@ -54,7 +54,7 @@ public void Equals_WhenSameInstance_MustReturnTrue()
/// <summary>
/// Tests IComparer.Equals.
/// </summary>
[Fact]
[Test]
public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue()
{
// Arrange
Expand All @@ -74,11 +74,11 @@ public void Equals_WhenSameInstanceAndObjectAttributeNull_MustReturnTrue()
/// <summary>
/// Tests IComparer.Equals.
/// </summary>
[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 };

Expand All @@ -92,12 +92,12 @@ public void Equals_WhenAttributeObjectsEqual_MustReturnTrue()
/// <summary>
/// Tests IComparer.Equals.
/// </summary>
[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 };

Expand All @@ -111,12 +111,12 @@ public void Equals_WhenBaseModelAttributeObjectsNotEqualButHaveSameValue_MustRet
/// <summary>
/// Tests IComparer.Equals.
/// </summary>
[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 };

Expand All @@ -130,12 +130,12 @@ public void Equals_WhenBaseModelAttributeObjectsNotEqualAndHaveDifferentValue_Mu
/// <summary>
/// Tests IComparer.Equals.
/// </summary>
[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 };

Expand All @@ -149,12 +149,12 @@ public void Equals_WhenAttributeObjectsNotEqualButNotRegistered_MustReturnTrue()
/// <summary>
/// Tests IComparer.Equals.
/// </summary>
[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<IComparerExclusion>
Expand All @@ -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<TestAttribute, ITestCompareIntention>
private class TestAttributeCompareRegistrations : ICompareRegistrations<TestWithProperties, ITestCompareIntention>
{
public void DoRegistrations(IEqualityComparerHelperRegistration<TestAttribute> registrations)
public void DoRegistrations(IEqualityComparerHelperRegistration<TestWithProperties> registrations)
{
registrations.Should().NotBeNull();

Expand Down
Loading

0 comments on commit 1d1874a

Please sign in to comment.