diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/DomainServiceFacts.cs b/src/ReliableUnitOfWork.SqlAzure.UnitTests/DomainServiceFacts.cs new file mode 100644 index 0000000..3e4ecbf --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/DomainServiceFacts.cs @@ -0,0 +1,22 @@ +using ReliableUnitOfWork.SqlAzure.Interfaces; +using Xunit; + +namespace ReliableUnitOfWork.SqlAzure.UnitTests +{ + public class DomainServiceFacts + { + private readonly IUnitOfWorkFactory unitOfWorkFactory = new UnitOfWorkFactory(); + private readonly TestPlayer1 player = new TestPlayer1(); + + [Fact] + public void ShouldCreateUnitOfWorkPerMethodAndJoinPlayersAccordingly() + { + var service = new TestService(unitOfWorkFactory, player); + + Assert.True(service.FirstCall()); + Assert.True(service.AnothertCall()); + Assert.True(service.FirstCall()); + Assert.True(service.AnothertCall()); + } + } +} \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj b/src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj index 1492af0..d7354f5 100644 --- a/src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj @@ -49,6 +49,7 @@ + diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs b/src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs index 228dcfe..e659fc1 100644 --- a/src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs @@ -1,4 +1,5 @@ using System; +using ReliableUnitOfWork.SqlAzure.Interfaces; namespace ReliableUnitOfWork.SqlAzure.UnitTests { @@ -27,4 +28,31 @@ protected override void HandlePlayerJoinedUnit(object sender, EventArgs e) TestPlayer1.Join(UnitOfWork); } } + + public class TestService : DomainService + { + private readonly TestPlayer1 player; + + public TestService(IUnitOfWorkFactory unitOfWorkFactory, TestPlayer1 testPlayer1) + : base(unitOfWorkFactory, testPlayer1) + { + player = testPlayer1; + } + + public bool FirstCall() + { + using (var uow = StartNewUnit()) + { + return uow.UniqueId == player.UnitOfWork.UniqueId; + } + } + + public bool AnothertCall() + { + using (var uow = StartNewUnit()) + { + return uow.UniqueId == player.UnitOfWork.UniqueId; + } + } + } } \ No newline at end of file