diff --git a/FileProcessor.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs b/FileProcessor.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs deleted file mode 100644 index 7215725..0000000 --- a/FileProcessor.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FileProcessor.BusinessLogic.Common -{ - using System.Data.Common; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using Microsoft.Data.SqlClient; - using Shared.General; - using Shared.Repositories; - - [ExcludeFromCodeCoverage] - public class ConfigurationReaderConnectionStringRepository : IConnectionStringConfigurationRepository - { - #region Methods - - public async Task CreateConnectionString(String externalIdentifier, - String connectionStringIdentifier, - String connectionString, - CancellationToken cancellationToken) - { - throw new NotImplementedException("This is only required to complete the interface"); - } - - public async Task DeleteConnectionStringConfiguration(String externalIdentifier, - String connectionStringIdentifier, - CancellationToken cancellationToken) - { - throw new NotImplementedException("This is only required to complete the interface"); - } - - public async Task GetConnectionString(String externalIdentifier, - String connectionStringIdentifier, - CancellationToken cancellationToken) - { - String connectionString = string.Empty; - String databaseName = string.Empty; - - databaseName = $"{connectionStringIdentifier}{externalIdentifier}"; - connectionString = ConfigurationReader.GetConnectionString(connectionStringIdentifier); - - DbConnectionStringBuilder builder = null; - - // Default to SQL Server - builder = new SqlConnectionStringBuilder(connectionString) - { - InitialCatalog = databaseName - }; - - return builder.ToString(); - } - - #endregion - } -} diff --git a/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj b/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj index d252481..1d5411b 100644 --- a/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj +++ b/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj @@ -6,12 +6,12 @@ - + - - + + - + diff --git a/FileProcessor.DataTransferObjects/FileProcessor.DataTransferObjects.csproj b/FileProcessor.DataTransferObjects/FileProcessor.DataTransferObjects.csproj index 3498a78..a745a64 100644 --- a/FileProcessor.DataTransferObjects/FileProcessor.DataTransferObjects.csproj +++ b/FileProcessor.DataTransferObjects/FileProcessor.DataTransferObjects.csproj @@ -6,7 +6,7 @@ - + diff --git a/FileProcessor.File.DomainEvents/FileProcessor.File.DomainEvents.csproj b/FileProcessor.File.DomainEvents/FileProcessor.File.DomainEvents.csproj index f861744..cbf9513 100644 --- a/FileProcessor.File.DomainEvents/FileProcessor.File.DomainEvents.csproj +++ b/FileProcessor.File.DomainEvents/FileProcessor.File.DomainEvents.csproj @@ -6,7 +6,7 @@ - + diff --git a/FileProcessor.FileAggregate.Tests/FileAggregateTests.cs b/FileProcessor.FileAggregate.Tests/FileAggregateTests.cs index 6a0b268..0c6aeab 100644 --- a/FileProcessor.FileAggregate.Tests/FileAggregateTests.cs +++ b/FileProcessor.FileAggregate.Tests/FileAggregateTests.cs @@ -27,7 +27,7 @@ public void FileAggregate_CanBeCreated_IsCreated() [Fact] public void FileAggregate_CanBeCreated_InvalidFileId_IsCreated() { - Should.Throw(() => { FileAggregate fileAggregate = FileAggregate.Create(Guid.Empty); }); + Should.Throw(() => { FileAggregate fileAggregate = FileAggregate.Create(Guid.Empty); }); } [Fact] diff --git a/FileProcessor.FileAggregate/FileAggregate.cs b/FileProcessor.FileAggregate/FileAggregate.cs index a2363ca..fe7a0ce 100644 --- a/FileProcessor.FileAggregate/FileAggregate.cs +++ b/FileProcessor.FileAggregate/FileAggregate.cs @@ -257,7 +257,8 @@ public FileAggregate() /// The aggregate identifier. private FileAggregate(Guid aggregateId) { - Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); + if (aggregateId== Guid.Empty) + throw new ArgumentException("Aggregate Id cannot be an Empty Guid"); this.AggregateId = aggregateId; this.FileLines = new List(); diff --git a/FileProcessor.FileAggregate/FileProcessor.FileAggregate.csproj b/FileProcessor.FileAggregate/FileProcessor.FileAggregate.csproj index 3ae864e..b57ee67 100644 --- a/FileProcessor.FileAggregate/FileProcessor.FileAggregate.csproj +++ b/FileProcessor.FileAggregate/FileProcessor.FileAggregate.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/FileProcessor.FileImportLog.DomainEvents/FileProcessor.FileImportLog.DomainEvents.csproj b/FileProcessor.FileImportLog.DomainEvents/FileProcessor.FileImportLog.DomainEvents.csproj index bd7b3ec..6fcf558 100644 --- a/FileProcessor.FileImportLog.DomainEvents/FileProcessor.FileImportLog.DomainEvents.csproj +++ b/FileProcessor.FileImportLog.DomainEvents/FileProcessor.FileImportLog.DomainEvents.csproj @@ -6,7 +6,7 @@ - + diff --git a/FileProcessor.FileImportLogAggregate/FileImportLogAggregate.cs b/FileProcessor.FileImportLogAggregate/FileImportLogAggregate.cs index 29d078e..3414d97 100644 --- a/FileProcessor.FileImportLogAggregate/FileImportLogAggregate.cs +++ b/FileProcessor.FileImportLogAggregate/FileImportLogAggregate.cs @@ -95,7 +95,8 @@ public FileImportLogAggregate() private FileImportLogAggregate(Guid aggregateId) { - Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); + if (aggregateId == Guid.Empty) + throw new ArgumentException("Aggregate Id cannot be an Empty Guid"); this.AggregateId = aggregateId; this.Files = new List(); diff --git a/FileProcessor.FileImportLogAggregate/FileProcessor.FileImportLogAggregate.csproj b/FileProcessor.FileImportLogAggregate/FileProcessor.FileImportLogAggregate.csproj index 728af80..8996cec 100644 --- a/FileProcessor.FileImportLogAggregate/FileProcessor.FileImportLogAggregate.csproj +++ b/FileProcessor.FileImportLogAggregate/FileProcessor.FileImportLogAggregate.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/FileProcessor.Tests/ControllerTests.cs b/FileProcessor.Tests/ControllerTests.cs deleted file mode 100644 index a08e5ed..0000000 --- a/FileProcessor.Tests/ControllerTests.cs +++ /dev/null @@ -1,71 +0,0 @@ -using FileProcessor.Controllers; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Moq; -using Newtonsoft.Json; -using Shared.EventStore.EventHandling; -using Shouldly; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Xunit; - -namespace FileProcessor.Tests -{ - using System.Threading; - using File.DomainEvents; - using Shared.General; - using Shared.Logger; - - public class ControllerTests - { - public ControllerTests() - { - Logger.Initialise(new NullLogger()); - } - [Fact] - public async Task DomainEventController_EventIdNotPresentInJson_ErrorThrown() - { - Mock resolver = new Mock(); - TypeMap.AddType("FileLineAddedEvent"); - DefaultHttpContext httpContext = new DefaultHttpContext(); - httpContext.Request.Headers["eventType"] = "FileLineAddedEvent"; - DomainEventController controller = new DomainEventController(resolver.Object) - { - ControllerContext = new ControllerContext() - { - HttpContext = httpContext - } - }; - String json = "{\r\n \"estateId\": \"435613ac-a468-47a3-ac4f-649d89764c22\",\r\n \"fileId\": \"17ee2309-ec79-dd25-0af9-f557e565feaa\",\r\n \"fileLine\": \"\",\r\n \"lineNumber\": 16\r\n}\t"; - Object request = JsonConvert.DeserializeObject(json); - ArgumentException ex = Should.Throw(async () => { - await controller.PostEventAsync(request, CancellationToken.None); - }); - ex.Message.ShouldBe("Domain Event must contain an Event Id"); - } - - [Fact] - public async Task DomainEventController_EventIdPresentInJson_NoErrorThrown() - { - Mock resolver = new Mock(); - TypeMap.AddType("FileLineAddedEvent"); - DefaultHttpContext httpContext = new DefaultHttpContext(); - httpContext.Request.Headers["eventType"] = "FileLineAddedEvent"; - DomainEventController controller = new DomainEventController(resolver.Object) - { - ControllerContext = new ControllerContext() - { - HttpContext = httpContext - } - }; - String json = "{\r\n \"estateId\": \"435613ac-a468-47a3-ac4f-649d89764c22\",\r\n \"fileId\": \"17ee2309-ec79-dd25-0af9-f557e565feaa\",\r\n \"fileLine\": \"\",\r\n \"lineNumber\": 16,\r\n \"eventId\": \"123456ac-a468-47a3-ac4f-649d89764b44\"\r\n}\t"; - Object request = JsonConvert.DeserializeObject(json); - Should.NotThrow(async () => { - await controller.PostEventAsync(request, CancellationToken.None); - }); - } - } -} diff --git a/FileProcessor.Tests/FileProcessor.Tests.csproj b/FileProcessor.Tests/FileProcessor.Tests.csproj index 84e6e25..45592bc 100644 --- a/FileProcessor.Tests/FileProcessor.Tests.csproj +++ b/FileProcessor.Tests/FileProcessor.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/FileProcessor/Bootstrapper/RepositoryRegistry.cs b/FileProcessor/Bootstrapper/RepositoryRegistry.cs index ee96e3f..9bbd6a8 100644 --- a/FileProcessor/Bootstrapper/RepositoryRegistry.cs +++ b/FileProcessor/Bootstrapper/RepositoryRegistry.cs @@ -13,12 +13,10 @@ namespace FileProcessor.Bootstrapper; using Microsoft.Extensions.Hosting; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EntityFramework; -using Shared.EntityFramework.ConnectionStringConfiguration; using Shared.EventStore.Aggregate; using Shared.EventStore.EventStore; using Shared.EventStore.SubscriptionWorker; using Shared.General; -using Shared.Repositories; using System; using System.Diagnostics.CodeAnalysis; diff --git a/FileProcessor/Controllers/DomainEventController.cs b/FileProcessor/Controllers/DomainEventController.cs index dc8a405..1c97a05 100644 --- a/FileProcessor/Controllers/DomainEventController.cs +++ b/FileProcessor/Controllers/DomainEventController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using SimpleResults; namespace FileProcessor.Controllers { @@ -119,15 +120,19 @@ private List GetDomainEventHandlers(IDomainEvent domainEven var eventHandlerType = this.Request.Headers["EventHandlerType"]; var resolver = Startup.Container.GetInstance(eventHandlerType); // We are being told by the caller to use a specific handler - var allhandlers = resolver.GetDomainEventHandlers(domainEvent); - var handlers = allhandlers.Where(h => h.GetType().Name.Contains(eventHandler)); + var allhandlersResult = resolver.GetDomainEventHandlers(domainEvent); + if (allhandlersResult.IsFailed) + return new List(); + var handlers = allhandlersResult.Data.Where(h => h.GetType().Name.Contains(eventHandler)); return handlers.ToList(); } - List eventHandlers = this.DomainEventHandlerResolver.GetDomainEventHandlers(domainEvent); - return eventHandlers; + Result> eventHandlersResult = this.DomainEventHandlerResolver.GetDomainEventHandlers(domainEvent); + if (eventHandlersResult.IsFailed) + return new List(); + return eventHandlersResult.Data; } private async Task GetDomainEvent(Object domainEvent) diff --git a/FileProcessor/FileProcessor.csproj b/FileProcessor/FileProcessor.csproj index c12a6eb..0870d0e 100644 --- a/FileProcessor/FileProcessor.csproj +++ b/FileProcessor/FileProcessor.csproj @@ -6,11 +6,11 @@ - + - + @@ -18,13 +18,13 @@ - - + + - + diff --git a/FileProcessor/Startup.cs b/FileProcessor/Startup.cs index c9c4957..1cd145b 100644 --- a/FileProcessor/Startup.cs +++ b/FileProcessor/Startup.cs @@ -1,60 +1,29 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using ImTools; namespace FileProcessor { using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.IO.Abstractions; using System.Reflection; using Bootstrapper; - using BusinessLogic.Common; - using BusinessLogic.EventHandling; - using BusinessLogic.FileFormatHandlers; - using BusinessLogic.Managers; - using BusinessLogic.RequestHandlers; - using BusinessLogic.Requests; using Common; - using EventStore.Client; - using File.DomainEvents; - using FileImportLog.DomainEvents; - using FileProcessor.Models; using HealthChecks.UI.Client; - using JasperFx.Core; using Lamar; - using MediatR; - using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; - using Microsoft.OpenApi.Models; - using Newtonsoft.Json; - using Newtonsoft.Json.Serialization; - using NLog.Extensions.Logging; - using SecurityService.Client; using Shared.DomainDrivenDesign.EventSourcing; - using Shared.EntityFramework; - using Shared.EntityFramework.ConnectionStringConfiguration; using Shared.EventStore.Aggregate; - using Shared.EventStore.EventStore; - using Shared.EventStore.Extensions; using Shared.Extensions; using Shared.General; using Shared.Logger; using Shared.Middleware; - using Shared.Repositories; - using Swashbuckle.AspNetCore.Filters; - using TransactionProcessor.Client; using ILogger = Microsoft.Extensions.Logging.ILogger; [ExcludeFromCodeCoverage]