diff --git a/.gitignore b/.gitignore
index 3e759b75..5ae0db95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
*.user
*.userosscache
*.sln.docstates
+*.[Dd]evelopment.json
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
diff --git a/EstateManagement.BusinessLogic/CommandHandlers/EstateCommandHandler.cs b/EstateManagement.BusinessLogic/CommandHandlers/EstateCommandHandler.cs
index e0f5bb20..1edd053e 100644
--- a/EstateManagement.BusinessLogic/CommandHandlers/EstateCommandHandler.cs
+++ b/EstateManagement.BusinessLogic/CommandHandlers/EstateCommandHandler.cs
@@ -1,5 +1,6 @@
namespace EstateManagement.BusinessLogic.CommandHandlers
{
+ using System;
using System.Threading;
using System.Threading.Tasks;
using Commands;
@@ -45,7 +46,15 @@ private async Task HandleCommand(CreateEstateCommand command,
estateAggregate.Register(command.Name);
- await this.EstateAggregateRepository.SaveChanges(estateAggregate, cancellationToken);
+ try
+ {
+ await this.EstateAggregateRepository.SaveChanges(estateAggregate, cancellationToken);
+ }
+ catch(Exception e)
+ {
+ throw;
+ }
+
}
#endregion
diff --git a/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj b/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj
index 72ee8a79..c9c86a76 100644
--- a/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj
+++ b/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj
@@ -10,8 +10,8 @@
-
-
+
+
diff --git a/EstateManagement.Client/EstateManagement.Client.csproj b/EstateManagement.Client/EstateManagement.Client.csproj
index 74fe609e..0df2546e 100644
--- a/EstateManagement.Client/EstateManagement.Client.csproj
+++ b/EstateManagement.Client/EstateManagement.Client.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj b/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj
index 38e862ec..69fc7661 100644
--- a/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj
+++ b/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj
@@ -5,6 +5,6 @@
-
+
diff --git a/EstateManagement.EstateAggregate.Tests/EstateManagement.EstateAggregate.Tests.csproj b/EstateManagement.EstateAggregate.Tests/EstateManagement.EstateAggregate.Tests.csproj
index 37bf1a17..da9b36ca 100644
--- a/EstateManagement.EstateAggregate.Tests/EstateManagement.EstateAggregate.Tests.csproj
+++ b/EstateManagement.EstateAggregate.Tests/EstateManagement.EstateAggregate.Tests.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/EstateManagement.EstateAggregate/EstateAggregate.cs b/EstateManagement.EstateAggregate/EstateAggregate.cs
index 8032e59d..41415849 100644
--- a/EstateManagement.EstateAggregate/EstateAggregate.cs
+++ b/EstateManagement.EstateAggregate/EstateAggregate.cs
@@ -84,6 +84,18 @@ public void Register(String estateName)
this.ApplyAndPend(estateCreatedEvent);
}
+ ///
+ /// Gets the metadata.
+ ///
+ ///
+ protected override Object GetMetadata()
+ {
+ return new
+ {
+ EstateId = this.AggregateId
+ };
+ }
+
///
/// Plays the event.
///
diff --git a/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj b/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj
index 0227088f..dcbef34f 100644
--- a/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj
+++ b/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj
@@ -5,9 +5,9 @@
-
-
-
+
+
+
diff --git a/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj b/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj
index ea4916bf..f130669b 100644
--- a/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj
+++ b/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/EstateManagement.Tests/Common/EstateManagementWebFactory.cs b/EstateManagement.Tests/Common/EstateManagementWebFactory.cs
index 1fddf2ed..ea0319d9 100644
--- a/EstateManagement.Tests/Common/EstateManagementWebFactory.cs
+++ b/EstateManagement.Tests/Common/EstateManagementWebFactory.cs
@@ -22,10 +22,10 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
builder.ConfigureServices((builderContext, services) =>
{
- if (commandRouterMock != null)
- {
- services.AddSingleton(commandRouterMock.Object);
- }
+ //if (commandRouterMock != null)
+ //{
+ // services.AddSingleton(commandRouterMock.Object);
+ //}
services.AddMvc(options =>
{
diff --git a/EstateManagement.Tests/ControllerTests/EstateControllerTests.cs b/EstateManagement.Tests/ControllerTests/EstateControllerTests.cs
index 7f0eaa00..893e6b7f 100644
--- a/EstateManagement.Tests/ControllerTests/EstateControllerTests.cs
+++ b/EstateManagement.Tests/ControllerTests/EstateControllerTests.cs
@@ -9,7 +9,11 @@
using DataTransferObjects.Requests;
using DataTransferObjects.Responses;
using EstateManagement.Testing;
+ using Lamar;
+ using Microsoft.Extensions.DependencyInjection;
+ using Moq;
using Newtonsoft.Json;
+ using Shared.DomainDrivenDesign.CommandHandling;
using Shouldly;
using Xunit;
@@ -32,11 +36,21 @@ public EstateControllerTests(EstateManagementWebFactory webApplicationF
this.WebApplicationFactory = webApplicationFactory;
}
- [Fact(Skip = "Lamar")]
+ [Fact(Skip="Issue with Lamar")]
public async Task GolfClubAdministratorController_POST_GolfClubAdministrator_GolfClubAdministratorIsReturned()
{
// 1. Arrange
HttpClient client = this.WebApplicationFactory.CreateClient();
+ var container = Startup.Container;
+
+ Mock commandRouterMock = new Mock(MockBehavior.Strict);
+
+ commandRouterMock.Setup(c => c.Route(It.IsAny(), It.IsAny())).Returns(Task.CompletedTask);
+
+ ServiceCollection services = new ServiceCollection();
+ services.AddSingleton(commandRouterMock.Object);
+
+ container.Configure(services);
CreateEstateRequest createEstateRequest = TestData.CreateEstateRequest;
String uri = "api/estates/";
diff --git a/EstateManagement/Controllers/EstateController.cs b/EstateManagement/Controllers/EstateController.cs
index b04d3f3e..471e0746 100644
--- a/EstateManagement/Controllers/EstateController.cs
+++ b/EstateManagement/Controllers/EstateController.cs
@@ -50,7 +50,7 @@ public class EstateController : ControllerBase
/// The command router.
/// The estate managment manager.
/// The model factory.
- public EstateController(CommandRouter commandRouter,
+ public EstateController(ICommandRouter commandRouter,
IEstateManagmentManager estateManagmentManager,
IModelFactory modelFactory)
{
diff --git a/EstateManagement/Startup.cs b/EstateManagement/Startup.cs
index 3ce15d9a..2a81043c 100644
--- a/EstateManagement/Startup.cs
+++ b/EstateManagement/Startup.cs
@@ -133,10 +133,10 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
ConfigurationReader.Initialise(Startup.Configuration);
- app.AddExceptionHandler();
app.AddRequestLogging();
app.AddResponseLogging();
-
+ app.AddExceptionHandler();
+
app.UseRouting();
app.UseAuthorization();
diff --git a/README.md b/README.md
index 40cfdeb0..71886931 100644
--- a/README.md
+++ b/README.md
@@ -12,3 +12,7 @@
## Code Coverage Results
[](https://coveralls.io/github/StuartFerguson/EstateManagement)
+
+## Code Quality Results
+
+[](https://www.codacy.com/manual/stuart_ferguson1/EstateManagement?utm_source=github.com&utm_medium=referral&utm_content=StuartFerguson/EstateManagement&utm_campaign=Badge_Grade)