Skip to content

Commit

Permalink
Moving to xUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien BIAUDET committed Aug 17, 2016
1 parent e16f1c0 commit f6bb4f6
Show file tree
Hide file tree
Showing 22 changed files with 220 additions and 113 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -13,6 +14,8 @@
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -46,17 +49,29 @@
<HintPath>..\..\..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="NinjectAggregateRootCreationStrategyTests.cs" />
Expand Down Expand Up @@ -84,6 +99,12 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace Ncqrs.Config.Ninject.Tests
{

[Specification]
public class NinjectAggregateRootCreationStrategyTests
: BaseTestFixture
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Ninject;
using FluentAssertions;
using NUnit.Framework;
using Xunit;

namespace Ncqrs.Config.Ninject.Tests
{
[TestFixture]
public class NinjectConfigurationTests
{
[Test]
[Fact]
public void When_component_is_registered_it_should_be_retrievable()
{
var kernel = new StandardKernel();
Expand All @@ -23,7 +22,7 @@ public void When_component_is_registered_it_should_be_retrievable()
component.Should().BeAssignableTo<IReplicant>();
}

[Test]
[Fact]
public void When_component_is_not_registered_it_should_not_be_retrievable()
{
var kernel = new StandardKernel();
Expand Down
8 changes: 7 additions & 1 deletion Extensions/src/Ncqrs.Config.Ninject.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
<packages>
<package id="FluentAssertions" version="4.12.0" targetFramework="net451" />
<package id="Ninject" version="3.2.2.0" targetFramework="net451" />
<package id="NUnit" version="3.4.1" targetFramework="net451" />
<package id="xunit" version="2.1.0" targetFramework="net451" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net451" />
<package id="xunit.assert" version="2.1.0" targetFramework="net451" />
<package id="xunit.core" version="2.1.0" targetFramework="net451" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net451" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net451" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net451" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Ncqrs.Config.Windsor.Tests
{
[Ignore("Error with mstest adapter")]

public class WindsorConfigurationEventBusTests
{
Expand All @@ -25,31 +24,31 @@ public void SetUp()
{
_testEvent = new UncommittedEvent(Guid.NewGuid(), Guid.NewGuid(), 1, 1, DateTime.UtcNow, new FakeEvent(),
new Version(1, 0));
_handler1 = new Mock<IEventHandler<FakeEvent>>();
_handler1.SetupAllProperties();
_handler2 = new Mock<IEventHandler<FakeEventBase>>();
_handler2.SetupAllProperties();
_handler3 = new Mock<IEventHandler<IFakeEventInterface>>();
_handler3.SetupAllProperties();
_handler1 = new Mock<IEventHandler<FakeEvent>>(MockBehavior.Strict);
_handler1.Setup(x => x.Handle(It.IsAny<IPublishedEvent<FakeEvent>>())).Verifiable();
_handler2 = new Mock<IEventHandler<FakeEventBase>>(MockBehavior.Strict);
_handler2.Setup(x => x.Handle(It.IsAny<IPublishedEvent<FakeEventBase>>())).Verifiable();
_handler3 = new Mock<IEventHandler<IFakeEventInterface>>(MockBehavior.Strict);
_handler3.Setup(x => x.Handle(It.IsAny<IPublishedEvent<IFakeEventInterface>>())).Verifiable();
_container = new WindsorContainer();
_container.Register(
Component.For<IWindsorContainer>().Instance(_container),
Component.For<IEventHandler<FakeEvent>>().Instance(_handler1.Object),
Component.For<IEventHandler<FakeEventBase>>().Instance(_handler2.Object),
Component.For<IEventHandler<IFakeEventInterface>>().Instance(_handler3.Object),
Component.For<IEventHandler<FakeEvent>>().Instance(_handler2.Object),
Component.For<IEventHandler<FakeEvent>>().Instance(_handler3.Object),
Component.For<IEventBus>().ImplementedBy<WindsorInProcessEventBus>());
var svc = _container.Resolve<IEventBus>();
svc.Publish(_testEvent);
}

[Test]
public void it_should_call_the_class_handler_once() { _handler1.Verify(x => x.Handle(null)); }
public void it_should_call_the_class_handler_once() { _handler1.Verify(x => x.Handle(It.IsAny<IPublishedEvent<FakeEvent>>())); }

[Test]
public void it_should_call_the_base_class_handler_once() { _handler2.Verify(x => x.Handle(null)); }
public void it_should_call_the_base_class_handler_once() { _handler2.Verify(x => x.Handle(It.IsAny<IPublishedEvent<FakeEventBase>>())); }

[Test]
public void it_should_call_the_interface_handler_once() { _handler3.Verify(x => x.Handle(null)); }
public void it_should_call_the_interface_handler_once() { _handler3.Verify(x => x.Handle(It.IsAny<IPublishedEvent<IFakeEventInterface>>())); }
}

public class FakeEvent : FakeEventBase, IFakeEventInterface { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Ncqrs.Domain;
using NUnit.Framework;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Ncqrs.Eventing.Sourcing.Snapshotting.DynamicSnapshot;
using Xunit;

namespace Ncqrs.Eventing.Sourcing.Snapshotting.DynamicSnapshot.Tests
{
[TestFixture]
[Ignore("Error with mstest adapter")]

public class SnapshotableProxyTests
public class SnapshotableProxyTests : IDisposable
{
private const string ChangedTitle = "ChangedTitle";

Expand All @@ -25,57 +23,57 @@ public class SnapshotableProxyTests

private readonly Guid AssemblyVersionGuid = Guid.Parse("938bab08-4f95-430f-b1b7-2200ae4085d5");

[Test]
[Fact]
public void CanBuildDynamicSnapshotAssembly()
{
var assembly = _container.Resolve<IDynamicSnapshotAssembly>();
var snapshotTypesCount = assembly.ActualAssembly.GetTypes().Length;
Assert.AreEqual(3, snapshotTypesCount);
Assert.Equal(3, snapshotTypesCount);
}

[Test]
[Fact]
public void CanChangeAssemblyVersionGuidTest()
{
var asm = _container.Resolve<IDynamicSnapshotAssembly>();
var MVID = asm.ActualAssembly.GetModule("DynamicSnapshot.dll").ModuleVersionId;
Assert.AreEqual(AssemblyVersionGuid, MVID);
Assert.Equal(AssemblyVersionGuid, MVID);
}

[Test]
[Fact]
public void CanCreateSnapshotableAggregate()
{
var proxy = _container.Resolve<Foo>();
Assert.IsNotNull(proxy);
Assert.NotNull(proxy);
}

[Test]
[Fact]
public void CanCreateSnapshot()
{
dynamic proxy = _container.Resolve<Foo>();
var snapshot = proxy.CreateSnapshot();
Assert.IsNotNull(snapshot);
Assert.NotNull(snapshot);
}

[Test]
[Fact]
public void CanProperlyRestoreFormDynamicSnapshot()
{
// We assert in each step!!!

dynamic proxy = _container.Resolve<Foo>();
proxy.ChangeTitle(OriginalTitle);
Assert.AreEqual(OriginalTitle, proxy.Tittle);
Assert.Equal(OriginalTitle, proxy.Tittle);

var snapshot = proxy.CreateSnapshot();
Assert.AreEqual(OriginalTitle, proxy.Tittle);
Assert.Equal(OriginalTitle, proxy.Tittle);

proxy.ChangeTitle(ChangedTitle);
Assert.AreEqual(ChangedTitle, proxy.Tittle);
Assert.Equal(ChangedTitle, proxy.Tittle);

proxy.RestoreFromSnapshot(snapshot);
Assert.AreEqual(OriginalTitle, proxy.Tittle);
Assert.Equal(OriginalTitle, proxy.Tittle);
}

[Test]
[Fact]
public void CanRestoreFromSerializedSnapshot()
{
if (!File.Exists(SerializedSnapshotFileName))
Expand All @@ -85,11 +83,10 @@ public void CanRestoreFromSerializedSnapshot()
object snapshot = DeserializeSnapshot();
proxy.RestoreFromSnapshot(snapshot);

Assert.AreEqual(OriginalTitle, proxy.Tittle);
Assert.Equal(OriginalTitle, proxy.Tittle);
}

[TestFixtureSetUp]
public void SetUp()
public SnapshotableProxyTests()
{
System.Diagnostics.Debug.Write("Initializing Windsor container...");
var target = Assembly.LoadFrom("Ncqrs.Eventing.Sourcing.Snapshotting.DynamicSnapshot.Tests.dll");
Expand All @@ -99,15 +96,15 @@ public void SetUp()
System.Diagnostics.Debug.WriteLine("Done!");
}

[TestFixtureTearDown]
public void TestFixtureTearDown()

public void Dispose()
{
if (File.Exists(SerializedSnapshotFileName))
File.Delete(SerializedSnapshotFileName);

dynamic proxy = _container.Resolve<Foo>();
proxy.ChangeTitle(OriginalTitle);
Assert.AreEqual(OriginalTitle, proxy.Tittle);
Assert.Equal(OriginalTitle, proxy.Tittle);

object snapshot = proxy.CreateSnapshot();
SerializeSnapshot(snapshot);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -13,6 +14,8 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -42,14 +45,26 @@
<HintPath>..\..\..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DynamicSnapshotTests.cs" />
Expand All @@ -74,6 +89,12 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
<packages>
<package id="Castle.Core" version="3.3.0" targetFramework="net452" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net452" />
<package id="NUnit" version="3.4.1" targetFramework="net452" />
<package id="xunit" version="2.1.0" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net452" />
<package id="xunit.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net452" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net452" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Ncqrs.Eventing.Storage.JOliver.Tests
{
[TestFixture]
[Ignore("Error with mstest adapter")]
public class AbsoluteOrderingSqlPersistenceEngineTests
{
private IPersistStreamsWithAbsoluteOrdering _sut;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="EventStore" connectionString="Data Source=(local);Initial Catalog=JoesTests;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="EventStore" connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=JoesTests;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup></configuration>
10 changes: 9 additions & 1 deletion Extensions/src/Ncqrs.Messaging.Tests/MessageServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Ncqrs.Messaging.Tests
{
[TestFixture]
[Ignore("Error with mstest adapter")]
public class MessageServiceTests
{
private MessageService _sut;
Expand Down Expand Up @@ -125,6 +124,15 @@ private void ResolveInvalidReceiver()

public class Receiver : MessagingAggregateRoot, IMessageHandler<TestMessage>
{
public Receiver():base()
{

}
public Receiver(Guid Id):base(Id)
{

}

void IMessageHandler<TestMessage>.Handle(TestMessage testMessage)
{
Reply(new TestMessage());
Expand Down
Loading

0 comments on commit f6bb4f6

Please sign in to comment.