From db17d2023abea3922c878b816d619b3a5f13bd08 Mon Sep 17 00:00:00 2001 From: Wahid Shalaly Date: Wed, 12 Mar 2014 18:03:53 +1100 Subject: [PATCH] Added unit tests for UnitOfWork & UnitOfWorkFactory. --- src/.nuget/packages.config | 4 + ...eliableUnitOfWork.SqlAzure.UnitTests.xunit | 6 ++ .../App.config | 13 ++++ .../Properties/AssemblyInfo.cs | 36 +++++++++ ...liableUnitOfWork.SqlAzure.UnitTests.csproj | 75 ++++++++++++++++++ .../TestObjects.cs | 30 ++++++++ .../UnitOfWorkFactoryFacts.cs | 76 +++++++++++++++++++ .../UnitOfWorkFacts.cs | 30 ++++++++ .../packages.config | 5 ++ src/ReliableUnitOfWork.SqlAzure.sln | 11 +++ .../DomainService.cs | 1 + .../Interfaces/IRepository.cs | 2 +- .../Interfaces/IUnitOfWorkFactory.cs | 2 +- .../Interfaces/IUnitOfWorkPlayer.cs | 4 +- .../{ => Internals}/DomainServiceBase.cs | 18 ++--- .../{ => Internals}/UnitOfWorkBase.cs | 20 ++--- .../{ => Internals}/UnitOfWorkFactoryBase.cs | 16 ++-- .../{ => Internals}/UnitOfWorkPlayerBase.cs | 67 ++++++++-------- .../ReliableUnitOfWork.SqlAzure.csproj | 8 +- src/ReliableUnitOfWork.SqlAzure/UnitOfWork.cs | 2 +- .../UnitOfWorkFactory.cs | 1 + .../UnitOfWorkPlayer.cs | 2 +- src/packages/repositories.config | 1 + 23 files changed, 363 insertions(+), 67 deletions(-) create mode 100644 src/.nuget/packages.config create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests.xunit create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests/App.config create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests/Properties/AssemblyInfo.cs create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFactoryFacts.cs create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFacts.cs create mode 100644 src/ReliableUnitOfWork.SqlAzure.UnitTests/packages.config rename src/ReliableUnitOfWork.SqlAzure/{ => Internals}/DomainServiceBase.cs (85%) rename src/ReliableUnitOfWork.SqlAzure/{ => Internals}/UnitOfWorkBase.cs (72%) rename src/ReliableUnitOfWork.SqlAzure/{ => Internals}/UnitOfWorkFactoryBase.cs (74%) rename src/ReliableUnitOfWork.SqlAzure/{ => Internals}/UnitOfWorkPlayerBase.cs (83%) diff --git a/src/.nuget/packages.config b/src/.nuget/packages.config new file mode 100644 index 0000000..eb41749 --- /dev/null +++ b/src/.nuget/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests.xunit b/src/ReliableUnitOfWork.SqlAzure.UnitTests.xunit new file mode 100644 index 0000000..1d173d3 --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests.xunit @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/App.config b/src/ReliableUnitOfWork.SqlAzure.UnitTests/App.config new file mode 100644 index 0000000..2fb423e --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/App.config @@ -0,0 +1,13 @@ + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/Properties/AssemblyInfo.cs b/src/ReliableUnitOfWork.SqlAzure.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d84f3a0 --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ReliableUnitOfWork.SqlAzure.UnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ReliableUnitOfWork.SqlAzure.UnitTests")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7d74f221-8745-4313-85e4-0310c58a3528")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj b/src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj new file mode 100644 index 0000000..1492af0 --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/ReliableUnitOfWork.SqlAzure.UnitTests.csproj @@ -0,0 +1,75 @@ + + + + + Debug + AnyCPU + {EA7B64E9-55F3-4987-BCAF-86B03C985009} + Library + Properties + ReliableUnitOfWork.SqlAzure.UnitTests + ReliableUnitOfWork.SqlAzure.UnitTests + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.0.2\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.0.2\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + ..\packages\xunit.1.9.2\lib\net20\xunit.dll + + + + + + + + + + + + + + + {c450e55f-cde0-4048-bba5-40c06833640f} + ReliableUnitOfWork.SqlAzure + + + + + \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs b/src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs new file mode 100644 index 0000000..228dcfe --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/TestObjects.cs @@ -0,0 +1,30 @@ +using System; + +namespace ReliableUnitOfWork.SqlAzure.UnitTests +{ + public class TestContext : UnitDbContext + { + } + + public class TestPlayer1 : UnitOfWorkPlayer + { + protected override void HandlePlayerJoinedUnit(object sender, EventArgs e) + { + } + } + + public class TestPlayer2 : UnitOfWorkPlayer + { + public readonly TestPlayer1 TestPlayer1; + + public TestPlayer2(TestPlayer1 testPlayer1) + { + TestPlayer1 = testPlayer1; + } + + protected override void HandlePlayerJoinedUnit(object sender, EventArgs e) + { + TestPlayer1.Join(UnitOfWork); + } + } +} \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFactoryFacts.cs b/src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFactoryFacts.cs new file mode 100644 index 0000000..5c2b688 --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFactoryFacts.cs @@ -0,0 +1,76 @@ +using ReliableUnitOfWork.SqlAzure.Interfaces; +using Xunit; + +namespace ReliableUnitOfWork.SqlAzure.UnitTests +{ + public class UnitOfWorkFactoryFacts + { + public class StartNew_WithoutParameters + { + private readonly IUnitOfWorkFactory unitOfWorkFactory = new UnitOfWorkFactory(); + + [Fact] + public void ShouldCreateNewUnitOfWork() + { + var unitOfWork = unitOfWorkFactory.StartNew(); + Assert.NotNull(unitOfWork); + Assert.NotNull(unitOfWork.DbContext); + Assert.IsType>(unitOfWork); + Assert.IsType(unitOfWork.DbContext); + } + } + + public class StartNew_WithPlayerHasNoDependencies + { + private readonly IUnitOfWorkFactory unitOfWorkFactory = new UnitOfWorkFactory(); + + [Fact] + public void ShouldCreateNewUnitOfWork() + { + var testPlayer1 = new TestPlayer1(); + var unitOfWork = unitOfWorkFactory.StartNew(testPlayer1); + + Assert.NotNull(unitOfWork); + Assert.NotNull(unitOfWork.DbContext); + Assert.IsType>(unitOfWork); + Assert.IsType(unitOfWork.DbContext); + } + + [Fact] + public void ShouldJoinPlayerToTheNewUnitOfWork() + { + var testPlayer1 = new TestPlayer1(); + var unitOfWork = unitOfWorkFactory.StartNew(testPlayer1); + + Assert.Equal(unitOfWork.UniqueId, testPlayer1.UnitOfWork.UniqueId); + } + } + + public class StartNew_WithPlayerHasDependencies + { + private readonly IUnitOfWorkFactory unitOfWorkFactory = new UnitOfWorkFactory(); + + [Fact] + public void ShouldCreateNewUnitOfWork() + { + var testPlayer1 = new TestPlayer1(); + var unitOfWork = unitOfWorkFactory.StartNew(testPlayer1); + + Assert.NotNull(unitOfWork); + Assert.NotNull(unitOfWork.DbContext); + Assert.IsType>(unitOfWork); + Assert.IsType(unitOfWork.DbContext); + } + + [Fact] + public void ShouldJoinPlayerAndDependenciesToTheNewUnitOfWork() + { + var testPlayer2 = new TestPlayer2(new TestPlayer1()); + var unitOfWork = unitOfWorkFactory.StartNew(testPlayer2); + + Assert.Equal(unitOfWork.UniqueId, testPlayer2.UnitOfWork.UniqueId); + Assert.Equal(unitOfWork.UniqueId, testPlayer2.TestPlayer1.UnitOfWork.UniqueId); + } + } + } +} \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFacts.cs b/src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFacts.cs new file mode 100644 index 0000000..669ebb1 --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/UnitOfWorkFacts.cs @@ -0,0 +1,30 @@ +using Xunit; + +namespace ReliableUnitOfWork.SqlAzure.UnitTests +{ + public class UnitOfWorkFacts + { + public class Constructor + { + [Fact] + public void ShouldCreateNewInstanceFromUnitDbContext() + { + var unitOfWork = new UnitOfWork(); + Assert.NotNull(unitOfWork.DbContext); + } + } + + public class Dispose + { + [Fact] + public void ShouldDisposeTheUnitDbContextToo() + { + var unitOfWork = new UnitOfWork(); + + unitOfWork.Dispose(); + + Assert.Null(unitOfWork.DbContext); + } + } + } +} diff --git a/src/ReliableUnitOfWork.SqlAzure.UnitTests/packages.config b/src/ReliableUnitOfWork.SqlAzure.UnitTests/packages.config new file mode 100644 index 0000000..636d76b --- /dev/null +++ b/src/ReliableUnitOfWork.SqlAzure.UnitTests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure.sln b/src/ReliableUnitOfWork.SqlAzure.sln index 1a069a1..7a89f8f 100644 --- a/src/ReliableUnitOfWork.SqlAzure.sln +++ b/src/ReliableUnitOfWork.SqlAzure.sln @@ -11,6 +11,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\ReliableUnitOfWork.SqlAzure.nuspec = ..\ReliableUnitOfWork.SqlAzure.nuspec EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReliableUnitOfWork.SqlAzure.UnitTests", "ReliableUnitOfWork.SqlAzure.UnitTests\ReliableUnitOfWork.SqlAzure.UnitTests.csproj", "{EA7B64E9-55F3-4987-BCAF-86B03C985009}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{AD1EF0E1-F9E6-400C-B444-79C02D8EC4DC}" + ProjectSection(SolutionItems) = preProject + .nuget\packages.config = .nuget\packages.config + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +28,10 @@ Global {C450E55F-CDE0-4048-BBA5-40C06833640F}.Debug|Any CPU.Build.0 = Debug|Any CPU {C450E55F-CDE0-4048-BBA5-40C06833640F}.Release|Any CPU.ActiveCfg = Release|Any CPU {C450E55F-CDE0-4048-BBA5-40C06833640F}.Release|Any CPU.Build.0 = Release|Any CPU + {EA7B64E9-55F3-4987-BCAF-86B03C985009}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA7B64E9-55F3-4987-BCAF-86B03C985009}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA7B64E9-55F3-4987-BCAF-86B03C985009}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA7B64E9-55F3-4987-BCAF-86B03C985009}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ReliableUnitOfWork.SqlAzure/DomainService.cs b/src/ReliableUnitOfWork.SqlAzure/DomainService.cs index 294f30b..dd70abb 100644 --- a/src/ReliableUnitOfWork.SqlAzure/DomainService.cs +++ b/src/ReliableUnitOfWork.SqlAzure/DomainService.cs @@ -1,4 +1,5 @@ using ReliableUnitOfWork.SqlAzure.Interfaces; +using ReliableUnitOfWork.SqlAzure.Internals; using Serilog; namespace ReliableUnitOfWork.SqlAzure diff --git a/src/ReliableUnitOfWork.SqlAzure/Interfaces/IRepository.cs b/src/ReliableUnitOfWork.SqlAzure/Interfaces/IRepository.cs index f0281f7..ba137c5 100644 --- a/src/ReliableUnitOfWork.SqlAzure/Interfaces/IRepository.cs +++ b/src/ReliableUnitOfWork.SqlAzure/Interfaces/IRepository.cs @@ -1,6 +1,6 @@ namespace ReliableUnitOfWork.SqlAzure.Interfaces { - public interface IRepository : IUnitOfWorkPlayer + public interface IRepository : IUnitOfWorkPlayer where TDbContext : IDbContext { } diff --git a/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkFactory.cs b/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkFactory.cs index d96cb52..9d0d424 100644 --- a/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkFactory.cs +++ b/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkFactory.cs @@ -1,6 +1,6 @@ namespace ReliableUnitOfWork.SqlAzure.Interfaces { - public interface IUnitOfWorkFactory : IUniqueIdHolder + public interface IUnitOfWorkFactory : IUniqueIdHolder where TDbContext : IDbContext { IUnitOfWork StartNew(params IUnitOfWorkPlayer[] players); diff --git a/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkPlayer.cs b/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkPlayer.cs index 15c783f..6572c02 100644 --- a/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkPlayer.cs +++ b/src/ReliableUnitOfWork.SqlAzure/Interfaces/IUnitOfWorkPlayer.cs @@ -1,8 +1,10 @@ namespace ReliableUnitOfWork.SqlAzure.Interfaces { - public interface IUnitOfWorkPlayer : IUniqueIdHolder + public interface IUnitOfWorkPlayer : IUniqueIdHolder where TDbContext : IDbContext { + IUnitOfWork UnitOfWork { get; } + void Join(IUnitOfWork unitOfWork); } } diff --git a/src/ReliableUnitOfWork.SqlAzure/DomainServiceBase.cs b/src/ReliableUnitOfWork.SqlAzure/Internals/DomainServiceBase.cs similarity index 85% rename from src/ReliableUnitOfWork.SqlAzure/DomainServiceBase.cs rename to src/ReliableUnitOfWork.SqlAzure/Internals/DomainServiceBase.cs index ff26709..b5d3380 100644 --- a/src/ReliableUnitOfWork.SqlAzure/DomainServiceBase.cs +++ b/src/ReliableUnitOfWork.SqlAzure/Internals/DomainServiceBase.cs @@ -1,10 +1,10 @@ -using ReliableUnitOfWork.SqlAzure.Interfaces; - -namespace ReliableUnitOfWork.SqlAzure -{ - public abstract class DomainServiceBase : UniqueIdHolder, IDomainService - where TDbContext : class, IDbContext, new() - { - public abstract IUnitOfWork StartNewUnit(); - } +using ReliableUnitOfWork.SqlAzure.Interfaces; + +namespace ReliableUnitOfWork.SqlAzure.Internals +{ + public abstract class DomainServiceBase : UniqueIdHolder, IDomainService + where TDbContext : class, IDbContext, new() + { + public abstract IUnitOfWork StartNewUnit(); + } } \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkBase.cs b/src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkBase.cs similarity index 72% rename from src/ReliableUnitOfWork.SqlAzure/UnitOfWorkBase.cs rename to src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkBase.cs index bbfdb7e..e2e0062 100644 --- a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkBase.cs +++ b/src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkBase.cs @@ -1,10 +1,12 @@ -namespace ReliableUnitOfWork.SqlAzure.Interfaces -{ - public abstract class UnitOfWorkBase : UniqueIdHolder, IUnitOfWork - where TDbContext : class, IDbContext, new() - { - public TDbContext DbContext { get; protected set; } - - public abstract void Dispose(); - } +using ReliableUnitOfWork.SqlAzure.Interfaces; + +namespace ReliableUnitOfWork.SqlAzure.Internals +{ + public abstract class UnitOfWorkBase : UniqueIdHolder, IUnitOfWork + where TDbContext : class, IDbContext, new() + { + public TDbContext DbContext { get; protected set; } + + public abstract void Dispose(); + } } \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkFactoryBase.cs b/src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkFactoryBase.cs similarity index 74% rename from src/ReliableUnitOfWork.SqlAzure/UnitOfWorkFactoryBase.cs rename to src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkFactoryBase.cs index 03e330f..ab8c3e5 100644 --- a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkFactoryBase.cs +++ b/src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkFactoryBase.cs @@ -1,8 +1,10 @@ -namespace ReliableUnitOfWork.SqlAzure.Interfaces -{ - public abstract class UnitOfWorkFactoryBase : UniqueIdHolder, IUnitOfWorkFactory - where TDbContext : class, IDbContext, new() - { - public abstract IUnitOfWork StartNew(params IUnitOfWorkPlayer[] players); - } +using ReliableUnitOfWork.SqlAzure.Interfaces; + +namespace ReliableUnitOfWork.SqlAzure.Internals +{ + public abstract class UnitOfWorkFactoryBase : UniqueIdHolder, IUnitOfWorkFactory + where TDbContext : class, IDbContext, new() + { + public abstract IUnitOfWork StartNew(params IUnitOfWorkPlayer[] players); + } } \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkPlayerBase.cs b/src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkPlayerBase.cs similarity index 83% rename from src/ReliableUnitOfWork.SqlAzure/UnitOfWorkPlayerBase.cs rename to src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkPlayerBase.cs index 9d23b3f..f81176d 100644 --- a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkPlayerBase.cs +++ b/src/ReliableUnitOfWork.SqlAzure/Internals/UnitOfWorkPlayerBase.cs @@ -1,34 +1,35 @@ -using System; - -namespace ReliableUnitOfWork.SqlAzure.Interfaces -{ - public abstract class UnitOfWorkPlayerBase : UniqueIdHolder, IUnitOfWorkPlayer - where TDbContext : class, IDbContext, new() - { - protected IUnitOfWork UnitOfWork { get; private set; } - - public event EventHandler PlayerJoinedUnit; - - protected UnitOfWorkPlayerBase() - { - PlayerJoinedUnit += HandlePlayerJoinedUnit; - } - - protected abstract void HandlePlayerJoinedUnit(object sender, EventArgs e); - - public void Join(IUnitOfWork unitOfWork) - { - if (unitOfWork == null) - throw new ArgumentNullException("unitOfWork"); - - UnitOfWork = unitOfWork; - OnPlayerJoinedUnit(); - } - - private void OnPlayerJoinedUnit() - { - if (PlayerJoinedUnit != null) - PlayerJoinedUnit(this, EventArgs.Empty); - } - } +using System; +using ReliableUnitOfWork.SqlAzure.Interfaces; + +namespace ReliableUnitOfWork.SqlAzure.Internals +{ + public abstract class UnitOfWorkPlayerBase : UniqueIdHolder, IUnitOfWorkPlayer + where TDbContext : class, IDbContext, new() + { + public IUnitOfWork UnitOfWork { get; private set; } + + public event EventHandler PlayerJoinedUnit; + + protected UnitOfWorkPlayerBase() + { + PlayerJoinedUnit += HandlePlayerJoinedUnit; + } + + protected abstract void HandlePlayerJoinedUnit(object sender, EventArgs e); + + public void Join(IUnitOfWork unitOfWork) + { + if (unitOfWork == null) + throw new ArgumentNullException("unitOfWork"); + + UnitOfWork = unitOfWork; + OnPlayerJoinedUnit(); + } + + private void OnPlayerJoinedUnit() + { + if (PlayerJoinedUnit != null) + PlayerJoinedUnit(this, EventArgs.Empty); + } + } } \ No newline at end of file diff --git a/src/ReliableUnitOfWork.SqlAzure/ReliableUnitOfWork.SqlAzure.csproj b/src/ReliableUnitOfWork.SqlAzure/ReliableUnitOfWork.SqlAzure.csproj index 66dfc00..ace1207 100644 --- a/src/ReliableUnitOfWork.SqlAzure/ReliableUnitOfWork.SqlAzure.csproj +++ b/src/ReliableUnitOfWork.SqlAzure/ReliableUnitOfWork.SqlAzure.csproj @@ -60,7 +60,7 @@ - + @@ -69,9 +69,9 @@ - - - + + + diff --git a/src/ReliableUnitOfWork.SqlAzure/UnitOfWork.cs b/src/ReliableUnitOfWork.SqlAzure/UnitOfWork.cs index edc75e2..99ac8f2 100644 --- a/src/ReliableUnitOfWork.SqlAzure/UnitOfWork.cs +++ b/src/ReliableUnitOfWork.SqlAzure/UnitOfWork.cs @@ -1,5 +1,5 @@ using System; -using ReliableUnitOfWork.SqlAzure.Interfaces; +using ReliableUnitOfWork.SqlAzure.Internals; using Serilog; namespace ReliableUnitOfWork.SqlAzure diff --git a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkFactory.cs b/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkFactory.cs index ca27db8..0e665b6 100644 --- a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkFactory.cs +++ b/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkFactory.cs @@ -1,4 +1,5 @@ using ReliableUnitOfWork.SqlAzure.Interfaces; +using ReliableUnitOfWork.SqlAzure.Internals; using Serilog; namespace ReliableUnitOfWork.SqlAzure diff --git a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkPlayer.cs b/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkPlayer.cs index 9d22329..3828543 100644 --- a/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkPlayer.cs +++ b/src/ReliableUnitOfWork.SqlAzure/UnitOfWorkPlayer.cs @@ -1,4 +1,4 @@ -using ReliableUnitOfWork.SqlAzure.Interfaces; +using ReliableUnitOfWork.SqlAzure.Internals; namespace ReliableUnitOfWork.SqlAzure { diff --git a/src/packages/repositories.config b/src/packages/repositories.config index 9be2707..540d810 100644 --- a/src/packages/repositories.config +++ b/src/packages/repositories.config @@ -1,4 +1,5 @@  + \ No newline at end of file