From 6109ebbdbb8a1e84312e8905eb057a5babe7a6f1 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Fri, 3 Jul 2020 12:26:31 +0100 Subject: [PATCH] Update to ES 20.05 completed --- .../TransactionAggregateManagerTests.cs | 57 +++-------- .../Services/TransactionDomainServiceTests.cs | 1 - ...actionProcessor.BusinessLogic.Tests.csproj | 2 +- .../Services/TransactionAggregateManager.cs | 81 +++++----------- .../TransactionProcessor.BusinessLogic.csproj | 10 +- .../TransactionProcessor.Client.csproj | 2 +- .../Common/DockerHelper.cs | 36 ++++--- .../LogonTransaction/LogonTransaction.feature | 6 ++ .../LogonTransaction.feature.cs | 65 +++++++------ .../SaleTransactionFeature.feature.cs | 26 ++--- .../Shared/SharedSteps.cs | 9 +- ...ansactionProcessor.IntegrationTests.csproj | 16 ++-- .../General/BootstrapperTests.cs | 3 +- .../TransactionProcessor.Tests.csproj | 2 +- ...nProcessor.Transaction.DomainEvents.csproj | 2 +- ...rocessor.TransactionAggregate.Tests.csproj | 2 +- .../TransactionAggregate.cs | 4 +- ...ctionProcessor.TransactionAggregate.csproj | 2 +- TransactionProcessor/Startup.cs | 95 ++++++++++--------- .../TransactionProcessor.csproj | 14 +-- TransactionProcessor/appsettings.json | 7 +- 21 files changed, 210 insertions(+), 232 deletions(-) diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs index 80bb2c5e..2042a1c2 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs @@ -9,7 +9,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using BusinessLogic.Services; using Models; using Moq; - using Shared.DomainDrivenDesign.EventStore; using Shared.EventStore.EventStore; using Shouldly; using Testing; @@ -23,9 +22,7 @@ public async Task TransactionAggregateManager_AuthoriseTransaction_TransactionAu { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.AuthoriseTransaction(TestData.EstateId, TestData.TransactionId, @@ -41,9 +38,7 @@ public async Task TransactionAggregateManager_AuthoriseTransactionLocally_Transa { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.AuthoriseTransactionLocally(TestData.EstateId, TestData.TransactionId, @@ -57,9 +52,7 @@ public async Task TransactionAggregateManager_DeclineTransaction_TransactionDecl { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.DeclineTransaction(TestData.EstateId, TestData.TransactionId, @@ -75,9 +68,7 @@ public async Task TransactionAggregateManager_DeclineTransactionLocally_Transact { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.DeclineTransactionLocally(TestData.EstateId, TestData.TransactionId, @@ -90,9 +81,7 @@ public async Task TransactionAggregateManager_GetAggregate_AggregateReturned() { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetCompletedTransactionAggregate); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); TransactionAggregate result = await transactionAggregateManager.GetAggregate(TestData.EstateId, TestData.TransactionId, @@ -106,9 +95,7 @@ public async Task TransactionAggregateManager_RecordAdditionalRequestData_Additi { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId, TestData.TransactionId, @@ -122,9 +109,7 @@ public async Task TransactionAggregateManager_RecordAdditionalRequestData_NullAd { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId, TestData.TransactionId, @@ -138,9 +123,7 @@ public async Task TransactionAggregateManager_RecordAdditionalRequestData_EmptyA { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId, TestData.TransactionId, @@ -154,9 +137,7 @@ public async Task TransactionAggregateManager_RecordAdditionalResponseData_Addit { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId, TestData.TransactionId, @@ -170,9 +151,7 @@ public async Task TransactionAggregateManager_RecordAdditionalResponseData_NullA { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId, TestData.TransactionId, @@ -186,9 +165,7 @@ public async Task TransactionAggregateManager_RecordAdditionalResponseData_Empty { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetStartedTransactionAggregate()); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId, TestData.TransactionId, @@ -204,9 +181,7 @@ public async Task TransactionAggregateManager_StartTransaction_TransactionStarte { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptyTransactionAggregate); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.StartTransaction(TestData.TransactionId, TestData.TransactionDateTime, @@ -225,9 +200,7 @@ public async Task TransactionAggregateManager_CompleteTransaction_TransactionCom { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetLocallyAuthorisedTransactionAggregate); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.CompleteTransaction(TestData.EstateId, TestData.TransactionId, @@ -239,9 +212,7 @@ public async Task TransactionAggregateManager_RequestEmailReceipt_EmailRecieptRe { Mock> aggregateRepository = new Mock>(); aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetCompletedTransactionAggregate); - Mock aggregateRepositoryManager = new Mock(); - aggregateRepositoryManager.Setup(a => a.GetAggregateRepository(It.IsAny())).Returns(aggregateRepository.Object); - TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepositoryManager.Object); + TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object); await transactionAggregateManager.RequestEmailReceipt(TestData.EstateId, TestData.TransactionId, diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs index 5487b2d4..40328702 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs @@ -16,7 +16,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using OperatorInterfaces; using SecurityService.Client; using SecurityService.DataTransferObjects.Responses; - using Shared.DomainDrivenDesign.EventStore; using Shared.EventStore.EventStore; using Shared.General; using Shared.Logger; diff --git a/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj b/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj index d9c90ae5..bc07a8c4 100644 --- a/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj +++ b/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs b/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs index 5ac1c489..eaf4c6ff 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionAggregateManager.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Internal; using Models; using OperatorInterfaces; - using Shared.DomainDrivenDesign.EventStore; using Shared.EventStore.EventStore; using TransactionAggregate; @@ -20,21 +19,21 @@ public class TransactionAggregateManager : ITransactionAggregateManager #region Fields /// - /// The aggregate repository manager + /// The transaction aggregate repository /// - private readonly IAggregateRepositoryManager AggregateRepositoryManager; + private readonly IAggregateRepository TransactionAggregateRepository; #endregion #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The aggregate repository manager. - public TransactionAggregateManager(IAggregateRepositoryManager aggregateRepositoryManager) + /// The transaction aggregate repository. + public TransactionAggregateManager(IAggregateRepository transactionAggregateRepository) { - this.AggregateRepositoryManager = aggregateRepositoryManager; + this.TransactionAggregateRepository = transactionAggregateRepository; } #endregion @@ -60,10 +59,7 @@ public async Task AuthoriseTransaction(Guid estateId, String responseMessage, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.AuthoriseTransaction(operatorIdentifier, operatorResponse.AuthorisationCode, @@ -73,7 +69,7 @@ public async Task AuthoriseTransaction(Guid estateId, ((Int32)transactionResponseCode).ToString().PadLeft(4, '0'), responseMessage); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } /// @@ -90,16 +86,13 @@ public async Task AuthoriseTransactionLocally(Guid estateId, (String responseMessage, TransactionResponseCode responseCode) validationResult, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.AuthoriseTransactionLocally(authorisationCode, ((Int32)validationResult.responseCode).ToString().PadLeft(4, '0'), validationResult.responseMessage); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } /// @@ -112,14 +105,11 @@ public async Task CompleteTransaction(Guid estateId, Guid transactionId, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.CompleteTransaction(); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } /// @@ -139,10 +129,7 @@ public async Task DeclineTransaction(Guid estateId, String responseMessage, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.DeclineTransaction(operatorIdentifier, operatorResponse.ResponseCode, @@ -150,7 +137,7 @@ public async Task DeclineTransaction(Guid estateId, ((Int32)transactionResponseCode).ToString().PadLeft(4, '0'), responseMessage); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } /// @@ -165,14 +152,11 @@ public async Task DeclineTransactionLocally(Guid estateId, (String responseMessage, TransactionResponseCode responseCode) validationResult, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.DeclineTransactionLocally(((Int32)validationResult.responseCode).ToString().PadLeft(4, '0'), validationResult.responseMessage); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } /// @@ -186,10 +170,7 @@ public async Task GetAggregate(Guid estateId, Guid transactionId, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); return transactionAggregate; } @@ -209,14 +190,11 @@ public async Task RecordAdditionalRequestData(Guid estateId, { if (additionalTransactionRequestMetadata != null && additionalTransactionRequestMetadata.Any()) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.RecordAdditionalRequestData(operatorIdentifier, additionalTransactionRequestMetadata); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } } @@ -235,14 +213,11 @@ public async Task RecordAdditionalResponseData(Guid estateId, { if (additionalTransactionResponseMetadata != null && additionalTransactionResponseMetadata.Any()) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.RecordAdditionalResponseData(operatorIdentifier, additionalTransactionResponseMetadata); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } } @@ -254,14 +229,11 @@ public async Task RecordAdditionalResponseData(Guid estateId, /// The cancellation token. public async Task RequestEmailReceipt(Guid estateId, Guid transactionId, String customerEmailAddress, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.RequestEmailReceipt(customerEmailAddress); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } /// @@ -288,14 +260,11 @@ public async Task StartTransaction(Guid transactionId, Decimal? transactionAmount, CancellationToken cancellationToken) { - IAggregateRepository transactionAggregateRepository = - this.AggregateRepositoryManager.GetAggregateRepository(estateId); - - TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); + TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken); transactionAggregate.StartTransaction(transactionDateTime, transactionNumber, transactionType, transactionReference, estateId, merchantId, deviceIdentifier, transactionAmount); - await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); + await this.TransactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken); } #endregion diff --git a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj index 35e92685..46fe7c06 100644 --- a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj +++ b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj @@ -5,12 +5,12 @@ - + - - - - + + + + diff --git a/TransactionProcessor.Client/TransactionProcessor.Client.csproj b/TransactionProcessor.Client/TransactionProcessor.Client.csproj index b449a109..6f3ae810 100644 --- a/TransactionProcessor.Client/TransactionProcessor.Client.csproj +++ b/TransactionProcessor.Client/TransactionProcessor.Client.csproj @@ -6,7 +6,7 @@ - + diff --git a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs index 28192d31..03264e31 100644 --- a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs +++ b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs @@ -17,9 +17,7 @@ using Ductus.FluentDocker.Services.Extensions; using EstateManagement.Client; using EstateReporting.Database; - using EventStore.ClientAPI.Common.Log; - using EventStore.ClientAPI.Projections; - using EventStore.ClientAPI.SystemData; + using EventStore.Client; using global::Shared.Logger; using Microsoft.Data.SqlClient; using SecurityService.Client; @@ -154,7 +152,6 @@ private async Task LoadEventStoreProjections() //Start our Continous Projections - we might decide to do this at a different stage, but now lets try here String projectionsFolder = "../../../projections/continuous"; IPAddress[] ipAddresses = Dns.GetHostAddresses("127.0.0.1"); - IPEndPoint endpoint = new IPEndPoint(ipAddresses.First(), this.EventStoreHttpPort); if (!String.IsNullOrWhiteSpace(projectionsFolder)) { @@ -164,8 +161,26 @@ private async Task LoadEventStoreProjections() { FileInfo[] files = di.GetFiles(); - // TODO: possibly need to change timeout and logger here - ProjectionsManager projectionManager = new ProjectionsManager(new ConsoleLogger(), endpoint, TimeSpan.FromSeconds(30)); + EventStoreClientSettings eventStoreClientSettings = new EventStoreClientSettings + { + ConnectivitySettings = new EventStoreClientConnectivitySettings + { + Address = new Uri($"https://{ipAddresses.First().ToString()}:{this.EventStoreHttpPort}") + }, + CreateHttpMessageHandler = () => new SocketsHttpHandler + { + SslOptions = + { + RemoteCertificateValidationCallback = (sender, + certificate, + chain, + errors) => true, + } + }, + DefaultCredentials = new UserCredentials("admin", "changeit") + + }; + EventStoreProjectionManagementClient projectionClient = new EventStoreProjectionManagementClient(eventStoreClientSettings); foreach (FileInfo file in files) { @@ -175,7 +190,7 @@ private async Task LoadEventStoreProjections() try { Logger.LogInformation($"Creating projection [{projectionName}]"); - await projectionManager.CreateContinuousAsync(projectionName, projection, new UserCredentials("admin", "changeit")).ConfigureAwait(false); + await projectionClient.CreateContinuousAsync(projectionName, projection).ConfigureAwait(false); } catch (Exception e) { @@ -218,22 +233,21 @@ public override async Task StartContainersForScenarioRun(String scenarioName) INetworkService testNetwork = DockerHelper.SetupTestNetwork(); this.TestNetworks.Add(testNetwork); - IContainerService eventStoreContainer = - DockerHelper.SetupEventStoreContainer(this.EventStoreContainerName, this.Logger, "eventstore/eventstore:release-5.0.2", testNetwork, traceFolder); + IContainerService eventStoreContainer = DockerHelper.SetupEventStoreContainer(this.EventStoreContainerName, this.Logger, "eventstore/eventstore:20.6.0-buster-slim", testNetwork, traceFolder, usesEventStore2006OrLater: true); IContainerService estateManagementContainer = DockerHelper.SetupEstateManagementContainer(this.EstateManagementContainerName, this.Logger, "stuartferguson/estatemanagement", new List { testNetwork, Setup.DatabaseServerNetwork - }, traceFolder, null, + }, traceFolder, dockerCredentials, this.SecurityServiceContainerName, this.EventStoreContainerName, (Setup.SqlServerContainerName, "sa", "thisisalongpassword123!"), ("serviceClient", "Secret1"), - true); + false); IContainerService securityServiceContainer = DockerHelper.SetupSecurityServiceContainer(this.SecurityServiceContainerName, this.Logger, diff --git a/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature b/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature index 9c9e9330..1e67998e 100644 --- a/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature +++ b/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature @@ -35,6 +35,12 @@ Background: | OperatorName | MerchantName | MerchantNumber | TerminalNumber | EstateName | | Test Operator 1 | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 | + #Given I make the following manual merchant deposits + #| Reference | Amount | DateTime | MerchantName | EstateName | + #| Deposit1 | 2000.00 | Today | Test Merchant 1 | Test Estate 1 | + #| Deposit1 | 1000.00 | Today | Test Merchant 2 | Test Estate 1 | + #| Deposit1 | 1000.00 | Today | Test Merchant 3 | Test Estate 2 | + @PRTest Scenario: Logon Transactions diff --git a/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs b/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs index d4f6a31a..e129ab63 100644 --- a/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs +++ b/TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs @@ -1,7 +1,7 @@ -// ------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // -// This code was generated by SpecFlow (http://www.specflow.org/). -// SpecFlow Version:3.1.0.0 +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.3.0.0 // SpecFlow Generator Version:3.1.0.0 // // Changes to this file may cause incorrect behavior and will be lost if @@ -17,7 +17,7 @@ namespace TransactionProcessor.IntegrationTests.LogonTransaction using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.1.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.3.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [Xunit.TraitAttribute("Category", "base")] [Xunit.TraitAttribute("Category", "shared")] @@ -220,9 +220,9 @@ public virtual void LogonTransactions() { string[] tagsOfScenario = new string[] { "PRTest"}; - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transactions", null, new string[] { - "PRTest"}); -#line 39 + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transactions", null, tagsOfScenario, argumentsOfScenario); +#line 45 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -273,7 +273,7 @@ public virtual void LogonTransactions() "Test Merchant 3", "123456782", "Test Estate 2"}); -#line 41 +#line 47 testRunner.When("I perform the following transactions", ((string)(null)), table8, "When "); #line hidden TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { @@ -300,7 +300,7 @@ public virtual void LogonTransactions() "3", "0000", "SUCCESS"}); -#line 47 +#line 53 testRunner.Then("transaction response should contain the following information", ((string)(null)), table9, "Then "); #line hidden } @@ -313,8 +313,9 @@ public virtual void LogonTransactions() public virtual void LogonTransactionWithExistingDevice() { string[] tagsOfScenario = ((string[])(null)); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Existing Device", null, ((string[])(null))); -#line 53 + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Existing Device", null, tagsOfScenario, argumentsOfScenario); +#line 59 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -347,7 +348,7 @@ public virtual void LogonTransactionWithExistingDevice() "Test Merchant 1", "00000001", "Test Estate 1"}); -#line 55 +#line 61 testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table10, "Given "); #line hidden TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] { @@ -364,7 +365,7 @@ public virtual void LogonTransactionWithExistingDevice() "Test Merchant 1", "123456780", "Test Estate 1"}); -#line 59 +#line 65 testRunner.When("I perform the following transactions", ((string)(null)), table11, "When "); #line hidden TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] { @@ -379,7 +380,7 @@ public virtual void LogonTransactionWithExistingDevice() "1", "0000", "SUCCESS"}); -#line 63 +#line 69 testRunner.Then("transaction response should contain the following information", ((string)(null)), table12, "Then "); #line hidden } @@ -394,9 +395,9 @@ public virtual void LogonTransactionWithInvalidDevice() { string[] tagsOfScenario = new string[] { "PRTest"}; - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Invalid Device", null, new string[] { - "PRTest"}); -#line 68 + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Invalid Device", null, tagsOfScenario, argumentsOfScenario); +#line 74 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -429,7 +430,7 @@ public virtual void LogonTransactionWithInvalidDevice() "Test Merchant 1", "00000001", "Test Estate 1"}); -#line 70 +#line 76 testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table13, "Given "); #line hidden TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] { @@ -446,7 +447,7 @@ public virtual void LogonTransactionWithInvalidDevice() "Test Merchant 1", "123456781", "Test Estate 1"}); -#line 74 +#line 80 testRunner.When("I perform the following transactions", ((string)(null)), table14, "When "); #line hidden TechTalk.SpecFlow.Table table15 = new TechTalk.SpecFlow.Table(new string[] { @@ -461,7 +462,7 @@ public virtual void LogonTransactionWithInvalidDevice() "1", "1000", "Device Identifier 123456781 not valid for Merchant Test Merchant 1"}); -#line 78 +#line 84 testRunner.Then("transaction response should contain the following information", ((string)(null)), table15, "Then "); #line hidden } @@ -474,8 +475,9 @@ public virtual void LogonTransactionWithInvalidDevice() public virtual void LogonTransactionWithInvalidEstate() { string[] tagsOfScenario = ((string[])(null)); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Invalid Estate", null, ((string[])(null))); -#line 82 + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Invalid Estate", null, tagsOfScenario, argumentsOfScenario); +#line 88 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -508,7 +510,7 @@ public virtual void LogonTransactionWithInvalidEstate() "Test Merchant 1", "00000001", "Test Estate 1"}); -#line 84 +#line 90 testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table16, "Given "); #line hidden TechTalk.SpecFlow.Table table17 = new TechTalk.SpecFlow.Table(new string[] { @@ -525,7 +527,7 @@ public virtual void LogonTransactionWithInvalidEstate() "Test Merchant 1", "123456781", "InvalidEstate"}); -#line 88 +#line 94 testRunner.When("I perform the following transactions", ((string)(null)), table17, "When "); #line hidden TechTalk.SpecFlow.Table table18 = new TechTalk.SpecFlow.Table(new string[] { @@ -540,7 +542,7 @@ public virtual void LogonTransactionWithInvalidEstate() "1", "1001", "Estate Id [79902550-64df-4491-b0c1-4e78943928a3] is not a valid estate"}); -#line 92 +#line 98 testRunner.Then("transaction response should contain the following information", ((string)(null)), table18, "Then "); #line hidden } @@ -553,8 +555,9 @@ public virtual void LogonTransactionWithInvalidEstate() public virtual void LogonTransactionWithInvalidMerchant() { string[] tagsOfScenario = ((string[])(null)); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Invalid Merchant", null, ((string[])(null))); -#line 96 + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction with Invalid Merchant", null, tagsOfScenario, argumentsOfScenario); +#line 102 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -587,7 +590,7 @@ public virtual void LogonTransactionWithInvalidMerchant() "Test Merchant 1", "00000001", "Test Estate 1"}); -#line 98 +#line 104 testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table19, "Given "); #line hidden TechTalk.SpecFlow.Table table20 = new TechTalk.SpecFlow.Table(new string[] { @@ -604,7 +607,7 @@ public virtual void LogonTransactionWithInvalidMerchant() "InvalidMerchant", "123456781", "Test Estate 1"}); -#line 102 +#line 108 testRunner.When("I perform the following transactions", ((string)(null)), table20, "When "); #line hidden TechTalk.SpecFlow.Table table21 = new TechTalk.SpecFlow.Table(new string[] { @@ -620,14 +623,14 @@ public virtual void LogonTransactionWithInvalidMerchant() "1002", "Merchant Id [d59320fa-4c3e-4900-a999-483f6a10c69a] is not a valid merchant for es" + "tate [Test Estate 1]"}); -#line 106 +#line 112 testRunner.Then("transaction response should contain the following information", ((string)(null)), table21, "Then "); #line hidden } this.ScenarioCleanup(); } - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.1.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.3.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class FixtureData : System.IDisposable { diff --git a/TransactionProcessor.IntegrationTests/SaleTransaction/SaleTransactionFeature.feature.cs b/TransactionProcessor.IntegrationTests/SaleTransaction/SaleTransactionFeature.feature.cs index 44ffe951..1ca10045 100644 --- a/TransactionProcessor.IntegrationTests/SaleTransaction/SaleTransactionFeature.feature.cs +++ b/TransactionProcessor.IntegrationTests/SaleTransaction/SaleTransactionFeature.feature.cs @@ -1,7 +1,7 @@ // ------------------------------------------------------------------------------ // -// This code was generated by SpecFlow (http://www.specflow.org/). -// SpecFlow Version:3.1.0.0 +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.3.0.0 // SpecFlow Generator Version:3.1.0.0 // // Changes to this file may cause incorrect behavior and will be lost if @@ -17,7 +17,7 @@ namespace TransactionProcessor.IntegrationTests.SaleTransaction using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.1.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.3.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [Xunit.TraitAttribute("Category", "base")] [Xunit.TraitAttribute("Category", "shared")] @@ -283,8 +283,8 @@ public virtual void SaleTransactions() { string[] tagsOfScenario = new string[] { "PRTest"}; - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transactions", null, new string[] { - "PRTest"}); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transactions", null, tagsOfScenario, argumentsOfScenario); #line 54 this.ScenarioInitialize(scenarioInfo); #line hidden @@ -411,8 +411,8 @@ public virtual void SaleTransactionWithInvalidDevice() { string[] tagsOfScenario = new string[] { "PRTest"}; - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Invalid Device", null, new string[] { - "PRTest"}); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Invalid Device", null, tagsOfScenario, argumentsOfScenario); #line 71 this.ScenarioInitialize(scenarioInfo); #line hidden @@ -486,7 +486,8 @@ public virtual void SaleTransactionWithInvalidDevice() public virtual void SaleTransactionWithInvalidEstate() { string[] tagsOfScenario = ((string[])(null)); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Invalid Estate", null, ((string[])(null))); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Invalid Estate", null, tagsOfScenario, argumentsOfScenario); #line 81 this.ScenarioInitialize(scenarioInfo); #line hidden @@ -560,7 +561,8 @@ public virtual void SaleTransactionWithInvalidEstate() public virtual void SaleTransactionWithInvalidMerchant() { string[] tagsOfScenario = ((string[])(null)); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Invalid Merchant", null, ((string[])(null))); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Invalid Merchant", null, tagsOfScenario, argumentsOfScenario); #line 91 this.ScenarioInitialize(scenarioInfo); #line hidden @@ -637,8 +639,8 @@ public virtual void SaleTransactionWithNotEnoughCreditAvailable() { string[] tagsOfScenario = new string[] { "PRTest"}; - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Not Enough Credit Available", null, new string[] { - "PRTest"}); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction with Not Enough Credit Available", null, tagsOfScenario, argumentsOfScenario); #line 102 this.ScenarioInitialize(scenarioInfo); #line hidden @@ -707,7 +709,7 @@ public virtual void SaleTransactionWithNotEnoughCreditAvailable() this.ScenarioCleanup(); } - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.1.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.3.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class FixtureData : System.IDisposable { diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 52f9fc22..6f729b50 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -212,9 +212,14 @@ public async Task WhenICreateTheFollowingMerchants(Table table) token = estateDetails.AccessToken; } - MerchantResponse merchant = await this.TestingContext.DockerHelper.EstateClient.GetMerchant(token, estateDetails.EstateId, merchantId, CancellationToken.None).ConfigureAwait(false); + await Retry.For(async () => + { + MerchantResponse merchant = await this.TestingContext.DockerHelper.EstateClient + .GetMerchant(token, estateDetails.EstateId, merchantId, CancellationToken.None) + .ConfigureAwait(false); - merchant.MerchantName.ShouldBe(merchantName); + merchant.MerchantName.ShouldBe(merchantName); + }); } } diff --git a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj index f39c4091..49cb5c3c 100644 --- a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj +++ b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj @@ -7,20 +7,20 @@ - + - + - + - - + + - - - + + + all diff --git a/TransactionProcessor.Tests/General/BootstrapperTests.cs b/TransactionProcessor.Tests/General/BootstrapperTests.cs index c60e77ba..61bae102 100644 --- a/TransactionProcessor.Tests/General/BootstrapperTests.cs +++ b/TransactionProcessor.Tests/General/BootstrapperTests.cs @@ -45,9 +45,8 @@ private IConfigurationRoot SetupMemoryConfiguration() IConfigurationBuilder builder = new ConfigurationBuilder(); - configuration.Add("EventStoreSettings:ConnectionString", "ConnectTo=tcp://admin:changeit@127.0.0.1:1112;VerboseLogging=true;"); + configuration.Add("EventStoreSettings:ConnectionString", "https://127.0.0.1:2113"); configuration.Add("EventStoreSettings:ConnectionName", "UnitTestConnection"); - configuration.Add("EventStoreSettings:HttpPort", "2113"); configuration.Add("AppSettings:UseConnectionStringConfig", "false"); configuration.Add("AppSettings:ClientId", "clientId"); configuration.Add("AppSettings:ClientSecret", "clientSecret"); diff --git a/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj b/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj index 1f7a599b..b914fcf3 100644 --- a/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj +++ b/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionProcessor.Transaction.DomainEvents.csproj b/TransactionProcessor.Transaction.DomainEvents/TransactionProcessor.Transaction.DomainEvents.csproj index 62d84c01..48303917 100644 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionProcessor.Transaction.DomainEvents.csproj +++ b/TransactionProcessor.Transaction.DomainEvents/TransactionProcessor.Transaction.DomainEvents.csproj @@ -5,7 +5,7 @@ - + diff --git a/TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj b/TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj index 1563578a..b3e2d7b0 100644 --- a/TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj +++ b/TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs b/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs index 80ce183b..9362baf5 100644 --- a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs +++ b/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs @@ -6,14 +6,14 @@ using System.Text.RegularExpressions; using Models; using Shared.DomainDrivenDesign.EventSourcing; - using Shared.DomainDrivenDesign.EventStore; + using Shared.EventStore.EventStore; using Shared.General; using Transaction.DomainEvents; /// /// /// - /// + /// public class TransactionAggregate : Aggregate { #region Fields diff --git a/TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj b/TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj index 3d2d639e..3a33bded 100644 --- a/TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj +++ b/TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj @@ -5,7 +5,7 @@ - + diff --git a/TransactionProcessor/Startup.cs b/TransactionProcessor/Startup.cs index eae2ff11..b67a5783 100644 --- a/TransactionProcessor/Startup.cs +++ b/TransactionProcessor/Startup.cs @@ -23,7 +23,7 @@ namespace TransactionProcessor using BusinessLogic.Services; using Common; using EstateManagement.Client; - using EventStore.ClientAPI; + using EventStore.Client; using MediatR; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Mvc.ApiExplorer; @@ -36,7 +36,6 @@ namespace TransactionProcessor using NLog.Extensions.Logging; using SecurityService.Client; using Shared.DomainDrivenDesign.CommandHandling; - using Shared.DomainDrivenDesign.EventStore; using Shared.EntityFramework.ConnectionStringConfiguration; using Shared.EventStore.EventStore; using Shared.Extensions; @@ -77,28 +76,7 @@ public void ConfigureServices(IServiceCollection services) Int32 httpPort = Startup.Configuration.GetValue("EventStoreSettings:HttpPort"); Boolean useConnectionStringConfig = Boolean.Parse(ConfigurationReader.GetValue("AppSettings", "UseConnectionStringConfig")); - EventStoreConnectionSettings settings = EventStoreConnectionSettings.Create(connString, connectionName, httpPort); - services.AddSingleton(settings); - - services.AddSingleton>(cont => (connectionSettings) => - { - return EventStoreConnection.Create(connectionSettings - .ConnectionString); - }); - - services.AddSingleton>(cont => (connectionString) => - { - EventStoreConnectionSettings connectionSettings = - EventStoreConnectionSettings.Create(connectionString, connectionName, httpPort); - - Func eventStoreConnectionFunc = cont.GetService>(); - - IEventStoreContext context = - new EventStoreContext(connectionSettings, eventStoreConnectionFunc); - - return context; - }); - + SafaricomConfiguration safaricomConfiguration = new SafaricomConfiguration(); if (Startup.Configuration != null) @@ -118,32 +96,63 @@ public void ConfigureServices(IServiceCollection services) String connectionStringConfigurationConnString = ConfigurationReader.GetConnectionString("ConnectionStringConfiguration"); services.AddSingleton(); services.AddTransient(c => - { - return new ConnectionStringConfigurationContext(connectionStringConfigurationConnString); - }); - - services.AddSingleton(c => - { - Func contextFunc = c.GetService>(); - IConnectionStringConfigurationRepository connectionStringConfigurationRepository = - c.GetService(); - return new EventStoreContextManager(contextFunc, - connectionStringConfigurationRepository); - }); + { + return new ConnectionStringConfigurationContext(connectionStringConfigurationConnString); + }); + + // TODO: Read this from a the database and set } else { - services.AddSingleton(c => - { - IEventStoreContext context = c.GetService(); - return new EventStoreContextManager(context); - }); - //services.AddSingleton(); + services.AddEventStoreClient((settings) => + { + settings.CreateHttpMessageHandler = () => new SocketsHttpHandler + { + SslOptions = + { + RemoteCertificateValidationCallback = (sender, + certificate, + chain, + errors) => true, + } + }; + settings.ConnectionName = Startup.Configuration.GetValue("EventStoreSettings:ConnectionName"); + settings.ConnectivitySettings = new EventStoreClientConnectivitySettings + { + Address = + new Uri(Startup.Configuration.GetValue("EventStoreSettings:ConnectionString")), + }; + settings.DefaultCredentials = new UserCredentials(Startup.Configuration.GetValue("EventStoreSettings:UserName"), + Startup.Configuration.GetValue("EventStoreSettings:Password")); + }); + + + + services.AddEventStoreProjectionManagerClient((settings) => + { + settings.CreateHttpMessageHandler = () => new SocketsHttpHandler + { + SslOptions = + { + RemoteCertificateValidationCallback = (sender, + certificate, + chain, + errors) => true, + } + }; + settings.ConnectionName = Startup.Configuration.GetValue("EventStoreSettings:ConnectionName"); + settings.ConnectivitySettings = new EventStoreClientConnectivitySettings + { + Address = + new Uri(Startup.Configuration.GetValue("EventStoreSettings:ConnectionString")) + }; + settings.DefaultCredentials = new UserCredentials(Startup.Configuration.GetValue("EventStoreSettings:UserName"), + Startup.Configuration.GetValue("EventStoreSettings:Password")); + }); } services.AddTransient(); services.AddSingleton(); - services.AddSingleton(); services.AddSingleton, AggregateRepository>(); services.AddSingleton(); services.AddSingleton(); diff --git a/TransactionProcessor/TransactionProcessor.csproj b/TransactionProcessor/TransactionProcessor.csproj index 0d30d107..39c3b75a 100644 --- a/TransactionProcessor/TransactionProcessor.csproj +++ b/TransactionProcessor/TransactionProcessor.csproj @@ -19,13 +19,13 @@ - - - - - - - + + + + + + + diff --git a/TransactionProcessor/appsettings.json b/TransactionProcessor/appsettings.json index 46271667..c6c7a21f 100644 --- a/TransactionProcessor/appsettings.json +++ b/TransactionProcessor/appsettings.json @@ -7,9 +7,10 @@ } }, "EventStoreSettings": { - "ConnectionString": "ConnectTo=tcp://admin:changeit@192.168.1.133:1113;VerboseLogging=true;", - "ConnectionName": "Estate Management", - "HttpPort": 2113, + "ConnectionString": "https://192.168.1.133:2113", + "ConnectionName": "Transaction Processor", + "UserName": "admin", + "Password": "changeit", "START_PROJECTIONS": false, "ContinuousProjectionsFolder": "" },