diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs index b154e90d..9ee7bb84 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs @@ -59,8 +59,6 @@ public async Task FloatDomainService_CreateFloatForContractProduct_FloatCreated( this.EstateClient.Setup(e => e.GetContract(It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny(), - It.IsAny(), It.IsAny())).ReturnsAsync(new ContractResponse{ EstateId = TestData.EstateId, ContractId = TestData.ContractId, @@ -90,8 +88,6 @@ public async Task FloatDomainService_CreateFloatForContractProduct_InvalidEstate this.EstateClient.Setup(e => e.GetContract(It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny(), - It.IsAny(), It.IsAny())).ReturnsAsync(new ContractResponse { EstateId = TestData.EstateId, @@ -146,8 +142,6 @@ public async Task FloatDomainService_CreateFloatForContractProduct_InvalidContra this.EstateClient.Setup(e => e.GetContract(It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny(), - It.IsAny(), It.IsAny())).ReturnsAsync(new ContractResponse { EstateId = TestData.EstateId, diff --git a/TransactionProcessor.BusinessLogic/Common/Extensions.cs b/TransactionProcessor.BusinessLogic/Common/Extensions.cs index b0ad214a..45e41483 100644 --- a/TransactionProcessor.BusinessLogic/Common/Extensions.cs +++ b/TransactionProcessor.BusinessLogic/Common/Extensions.cs @@ -10,6 +10,10 @@ namespace TransactionProcessor.BusinessLogic.Common using System.Diagnostics.CodeAnalysis; using Shared.General; using Type = System.Type; + using System.Threading; + using SecurityService.Client; + using SecurityService.DataTransferObjects.Responses; + using Shared.Logger; public static class Helpers { @@ -20,6 +24,32 @@ public static Guid CalculateSettlementAggregateId(DateTime settlementDate, Guid aggregateId = GuidCalculator.Combine(estateId,merchantId, settlementDate.ToGuid()); return aggregateId; } + + public static async Task GetToken(TokenResponse currentToken, ISecurityServiceClient securityServiceClient, CancellationToken cancellationToken) + { + // Get a token to talk to the estate service + String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); + String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); + Logger.LogDebug($"Client Id is {clientId}"); + Logger.LogDebug($"Client Secret is {clientSecret}"); + + if (currentToken == null) + { + TokenResponse token = await securityServiceClient.GetToken(clientId, clientSecret, cancellationToken); + Logger.LogDebug($"Token is {token.AccessToken}"); + return token; + } + + if (currentToken.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)) + { + Logger.LogDebug($"Token is about to expire at {currentToken.Expires.DateTime:O}"); + TokenResponse token = await securityServiceClient.GetToken(clientId, clientSecret, cancellationToken); + Logger.LogDebug($"Token is {token.AccessToken}"); + return token; + } + + return currentToken; + } } public static class Extensions diff --git a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs index 91bc0280..16835433 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs @@ -120,36 +120,7 @@ private DateTime CalculateSettlementDate(SettlementSchedule merchantSettlementSc return completeDateTime.Date; } - - /// - /// Gets the token. - /// - /// The cancellation token. - /// - [ExcludeFromCodeCoverage] - private async Task GetToken(CancellationToken cancellationToken) { - // Get a token to talk to the estate service - String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); - String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogInformation($"Client Id is {clientId}"); - Logger.LogInformation($"Client Secret is {clientSecret}"); - - if (this.TokenResponse == null) { - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)) { - Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}"); - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - return this.TokenResponse; - } - + private Boolean RequireFeeCalculation(TransactionAggregate transactionAggregate){ return transactionAggregate switch{ _ when transactionAggregate.IsAuthorised == false => false, @@ -197,7 +168,7 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do if (RequireFeeCalculation(transactionAggregate) == false) return; - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); List feesForCalculation = await this.GetTransactionFeesForCalculation(transactionAggregate, cancellationToken); @@ -345,7 +316,7 @@ private async Task> GetTransactionFeesForCalcula private async Task HandleSpecificDomainEvent(CustomerEmailReceiptRequestedEvent domainEvent, CancellationToken cancellationToken) { - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); TransactionAggregate transactionAggregate = await this.TransactionAggregateRepository.GetLatestVersion(domainEvent.TransactionId, cancellationToken); @@ -368,7 +339,7 @@ await this.SendEmailMessage(this.TokenResponse.AccessToken, private async Task HandleSpecificDomainEvent(CustomerEmailReceiptResendRequestedEvent domainEvent, CancellationToken cancellationToken) { - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); // Send the message await this.ResendEmailMessage(this.TokenResponse.AccessToken, domainEvent.EventId, domainEvent.EstateId, cancellationToken); diff --git a/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs index ed86a270..4328912b 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; +using Common; using EstateManagement.Database.Contexts; using EstateManagement.Database.Entities; using MessagingService.Client; @@ -125,39 +126,7 @@ public async Task Handle(IDomainEvent domainEvent, { await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken); } - - /// - /// Gets the token. - /// - /// The cancellation token. - /// - [ExcludeFromCodeCoverage] - private async Task GetToken(CancellationToken cancellationToken) - { - // Get a token to talk to the estate service - String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); - String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogInformation($"Client Id is {clientId}"); - Logger.LogInformation($"Client Secret is {clientSecret}"); - - if (this.TokenResponse == null) - { - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)) - { - Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}"); - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - return this.TokenResponse; - } - + /// /// Gets the voucher operator. /// @@ -186,7 +155,7 @@ private async Task HandleSpecificDomainEvent(VoucherIssuedEvent domainEvent, // Get the voucher aggregate VoucherAggregate voucherAggregate = await this.VoucherAggregateRepository.GetLatestVersion(domainEvent.AggregateId, cancellationToken); Models.Voucher voucherModel = voucherAggregate.GetVoucher(); - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); if (string.IsNullOrEmpty(voucherModel.RecipientEmail) == false) { String message = await this.GetEmailVoucherMessage(voucherModel, cancellationToken); diff --git a/TransactionProcessor.BusinessLogic/Services/IFloatDomainService.cs b/TransactionProcessor.BusinessLogic/Services/IFloatDomainService.cs index 263957a7..fec9677d 100644 --- a/TransactionProcessor.BusinessLogic/Services/IFloatDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/IFloatDomainService.cs @@ -9,6 +9,7 @@ namespace TransactionProcessor.BusinessLogic.Services using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Threading; + using Common; using EstateManagement.Client; using EstateManagement.Database.Entities; using EstateManagement.DataTransferObjects.Responses; @@ -48,36 +49,10 @@ public FloatDomainService(IAggregateRepository floa private TokenResponse TokenResponse; - [ExcludeFromCodeCoverage] - private async Task GetToken(CancellationToken cancellationToken) - { - // Get a token to talk to the estate service - String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); - String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogInformation($"Client Id is {clientId}"); - Logger.LogInformation($"Client Secret is {clientSecret}"); - - if (this.TokenResponse == null) - { - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)) - { - Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}"); - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - return this.TokenResponse; - } private async Task ValidateEstate(Guid estateId, CancellationToken cancellationToken) { - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); EstateResponse estate = await this.EstateClient.GetEstate(this.TokenResponse.AccessToken, estateId, cancellationToken); @@ -88,10 +63,10 @@ private async Task ValidateEstate(Guid estateId, CancellationToken cancellationT private async Task ValidateContractProduct(Guid estateId, Guid contractId, Guid productId, CancellationToken cancellationToken) { - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); // TODO: validate the estate, contract and product - ContractResponse contract = await this.EstateClient.GetContract(this.TokenResponse.AccessToken, estateId, contractId, true, false, cancellationToken); + ContractResponse contract = await this.EstateClient.GetContract(this.TokenResponse.AccessToken, estateId, contractId, cancellationToken); if (contract == null) { diff --git a/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs b/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs index 7ca36133..0ab9c6ee 100644 --- a/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs @@ -47,7 +47,7 @@ public async Task ProcessSettlement(DateTime settleme return response; } - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); MerchantResponse merchant = await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, estateId, @@ -108,32 +108,5 @@ public SettlementDomainService(IAggregateRepository GetToken(CancellationToken cancellationToken) - { - // Get a token to talk to the estate service - String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); - String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogInformation($"Client Id is {clientId}"); - Logger.LogInformation($"Client Secret is {clientSecret}"); - - if (this.TokenResponse == null) - { - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)) - { - Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}"); - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - return this.TokenResponse; - } } } \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs index 97b5152c..e230b955 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs @@ -338,7 +338,7 @@ private async Task AddDeviceToMerchant(Guid estateId, Guid merchantId, String deviceIdentifier, CancellationToken cancellationToken){ - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); // Add the device to the merchant await this.EstateClient.AddDeviceToMerchant(this.TokenResponse.AccessToken, @@ -367,37 +367,13 @@ private String GenerateTransactionReference(){ private async Task GetMerchant(Guid estateId, Guid merchantId, CancellationToken cancellationToken){ - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); MerchantResponse merchant = await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, estateId, merchantId, cancellationToken); return merchant; } - - [ExcludeFromCodeCoverage] - private async Task GetToken(CancellationToken cancellationToken){ - // Get a token to talk to the estate service - String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); - String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogInformation($"Client Id is {clientId}"); - Logger.LogInformation($"Client Secret is {clientSecret}"); - - if (this.TokenResponse == null){ - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)){ - Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}"); - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - return this.TokenResponse; - } - + private async Task ProcessMessageWithOperator(MerchantResponse merchant, Guid transactionId, DateTime transactionDateTime, diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs index 37d1d590..14d19c03 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Common; using EstateManagement.Client; using EstateManagement.DataTransferObjects.Responses; using EventStore.Client; @@ -173,8 +174,8 @@ public TransactionValidationService(IEstateClient estateClient, throw new TransactionValidationException($"Contract Id [{contractId}] must be set for a sale transaction", TransactionResponseCode.InvalidContractIdValue); } - - List merchantContracts = null; + + List merchantContracts = null; try{ merchantContracts = await this.GetMerchantContracts(estateId, merchantId, cancellationToken); } @@ -191,7 +192,7 @@ public TransactionValidationService(IEstateClient estateClient, } // Check the contract and product id against the merchant - ContractResponse contract = merchantContracts.SingleOrDefault(c => c.ContractId == contractId); + MerchantContractResponse contract = merchantContracts.SingleOrDefault(c => c.ContractId == contractId); if (contract == null){ throw new TransactionValidationException($"Contract Id [{contractId}] not valid for Merchant [{merchant.MerchantName}]", @@ -203,9 +204,9 @@ public TransactionValidationService(IEstateClient estateClient, TransactionResponseCode.InvalidProductIdValue); } - ContractProduct contractProduct = contract.Products.SingleOrDefault(p => p.ProductId == productId); + Guid contractProduct = contract.ContractProducts.SingleOrDefault(p => p == productId); - if (contractProduct == null){ + if (contractProduct == Guid.Empty){ throw new TransactionValidationException($"Product Id [{productId}] not valid for Merchant [{merchant.MerchantName}]", TransactionResponseCode.ProductNotValidForMerchant); } @@ -237,7 +238,7 @@ public TransactionValidationService(IEstateClient estateClient, private async Task GetEstate(Guid estateId, CancellationToken cancellationToken){ - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); EstateResponse estate = await this.EstateClient.GetEstate(this.TokenResponse.AccessToken, estateId, cancellationToken); @@ -247,47 +248,24 @@ private async Task GetEstate(Guid estateId, private async Task GetMerchant(Guid estateId, Guid merchantId, CancellationToken cancellationToken){ - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); MerchantResponse merchant = await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, estateId, merchantId, cancellationToken); - + return merchant; } - private async Task> GetMerchantContracts(Guid estateId, + private async Task> GetMerchantContracts(Guid estateId, Guid merchantId, - CancellationToken cancellationToken){ - this.TokenResponse = await this.GetToken(cancellationToken); - - List merchantContracts = await this.EstateClient.GetMerchantContracts(this.TokenResponse.AccessToken, estateId, merchantId, cancellationToken); - - return merchantContracts; - } - - [ExcludeFromCodeCoverage] - private async Task GetToken(CancellationToken cancellationToken){ - // Get a token to talk to the estate service - String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); - String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogInformation($"Client Id is {clientId}"); - Logger.LogInformation($"Client Secret is {clientSecret}"); - - if (this.TokenResponse == null){ - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } + CancellationToken cancellationToken) + { + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); - if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)){ - Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}"); - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } + MerchantResponse merchant = await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, estateId, merchantId, cancellationToken); - return this.TokenResponse; + return merchant.Contracts; } - + private async Task<(EstateResponse estate, MerchantResponse merchant)> ValidateMerchant(Guid estateId, Guid merchantId, CancellationToken cancellationToken){ diff --git a/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs b/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs index 500c49a5..1e784544 100644 --- a/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Common; using EstateManagement.Client; using EstateManagement.Database.Contexts; using EstateManagement.DataTransferObjects.Responses; @@ -238,43 +239,12 @@ private async Task ValidateVoucherRedemption(Guid estateId, Canc private async Task GetEstate(Guid estateId, CancellationToken cancellationToken) { - this.TokenResponse = await this.GetToken(cancellationToken); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); EstateResponse estate = await this.EstateClient.GetEstate(this.TokenResponse.AccessToken, estateId, cancellationToken); return estate; } - - /// - /// Gets the token. - /// - /// The cancellation token. - /// - private async Task GetToken(CancellationToken cancellationToken) - { - // Get a token to talk to the estate service - String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); - String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogInformation($"Client Id is {clientId}"); - Logger.LogInformation($"Client Secret is {clientSecret}"); - - if (this.TokenResponse == null) - { - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)) - { - Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}"); - TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken); - Logger.LogInformation($"Token is {token.AccessToken}"); - return token; - } - - return this.TokenResponse; - } - + #endregion } \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj index 007d38f3..8fff339e 100644 --- a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj +++ b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj @@ -5,7 +5,7 @@ - + diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj index 6c7a034a..cc964bae 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj @@ -7,7 +7,7 @@ - + diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs index 7685afd7..81715c16 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs @@ -33,6 +33,16 @@ public async Task WhenIPerformTheFollowingTransactions(String accessToken, List< } } + public async Task WhenICreateTheFollowingMerchants(String accessToken, Guid estateId, Guid merchantId){ + await Retry.For(async () => { + MerchantBalanceResponse response = await this.TransactionProcessorClient.GetMerchantBalance(accessToken, estateId, merchantId, CancellationToken.None); + + response.ShouldNotBeNull(); + }, + TimeSpan.FromMinutes(2), + TimeSpan.FromSeconds(30)); + } + public void ValidateTransactions(List<(SerialisedMessage, String, String, String)> transactions) { foreach ((SerialisedMessage, String, String, String) transaction in transactions) diff --git a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs index ec960068..7e7b919a 100644 --- a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs +++ b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs @@ -8,6 +8,7 @@ using Client; using EstateManagement.Client; using EstateManagement.Database.Contexts; + using EventStore.Client; using global::Shared.IntegrationTesting; using SecurityService.Client; using Retry = IntegrationTests.Retry; @@ -40,6 +41,8 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper private readonly TestingContext TestingContext; + public EventStoreProjectionManagementClient ProjectionManagementClient; + #endregion #region Constructors @@ -86,6 +89,8 @@ public override async Task StartContainersForScenarioRun(String scenarioName, Do this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient); this.TestHostHttpClient= new HttpClient(clientHandler); this.TestHostHttpClient.BaseAddress = new Uri($"http://127.0.0.1:{this.TestHostServicePort}"); + + this.ProjectionManagementClient = new EventStoreProjectionManagementClient(ConfigureEventStoreSettings()); } /// @@ -116,6 +121,18 @@ await Retry.For(async () => } } + public override async Task CreateGenericSubscriptions(){ + List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new List<(String streamName, String groupName, Int32 maxRetries)> + { + ($"$ce-MerchantBalanceArchive", "Transaction Processor - Ordered", 2), + ($"$et-EstateCreatedEvent", "Transaction Processor - Ordered", 2) + }; + foreach ((String streamName, String groupName, Int32 maxRetries) subscription in subscriptions) + { + await this.CreatePersistentSubscription(subscription); + } + } + #endregion } } \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature b/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature index 6015fcdb..b2ae741b 100644 --- a/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature +++ b/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature @@ -55,6 +55,10 @@ Background: | Reference | Amount | DateTime | MerchantName | EstateName | | Deposit1 | 20.00 | Today | Test Merchant 1 | Test Estate 1 | + When I add the following contracts to the following merchants + | EstateName | MerchantName | ContractDescription | + | Test Estate 1 | Test Merchant 1 | Hospital 1 Contract | + When I perform the following transactions | DateTime | TransactionNumber | TransactionType | TransactionSource | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName | RecipientEmail | RecipientMobile | MessageType | AccountNumber | CustomerName | | Today | 1 | Sale | 1 | Test Merchant 1 | 123456780 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | | | | diff --git a/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs b/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs index 41397e74..79758672 100644 --- a/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs @@ -257,6 +257,17 @@ public virtual void FeatureBackground() testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table46, "Given "); #line hidden TechTalk.SpecFlow.Table table47 = new TechTalk.SpecFlow.Table(new string[] { + "EstateName", + "MerchantName", + "ContractDescription"}); + table47.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "Hospital 1 Contract"}); +#line 58 + testRunner.When("I add the following contracts to the following merchants", ((string)(null)), table47, "When "); +#line hidden + TechTalk.SpecFlow.Table table48 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -275,7 +286,7 @@ public virtual void FeatureBackground() "MessageType", "AccountNumber", "CustomerName"}); - table47.AddRow(new string[] { + table48.AddRow(new string[] { "Today", "1", "Sale", @@ -294,8 +305,8 @@ public virtual void FeatureBackground() "", "", ""}); -#line 58 - testRunner.When("I perform the following transactions", ((string)(null)), table47, "When "); +#line 62 + testRunner.When("I perform the following transactions", ((string)(null)), table48, "When "); #line hidden } @@ -314,7 +325,7 @@ public void RedeemVouchers() "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Redeem Vouchers", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 64 +#line 68 this.ScenarioInitialize(scenarioInfo); #line hidden if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) @@ -327,7 +338,7 @@ public void RedeemVouchers() #line 5 this.FeatureBackground(); #line hidden -#line 65 +#line 69 testRunner.When("I redeem the voucher for Estate \'Test Estate 1\' and Merchant \'Test Merchant 1\' tr" + "ansaction number 1 the voucher balance will be 0", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden diff --git a/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature b/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature index 1dd30031..a5f2294f 100644 --- a/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature +++ b/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature @@ -88,6 +88,21 @@ Background: | Deposit1 | 110.00 | Today | Test Merchant 3 | Test Estate 1 | | Deposit1 | 100.00 | Today | Test Merchant 4 | Test Estate 1 | + When I add the following contracts to the following merchants + | EstateName | MerchantName | ContractDescription | + | Test Estate 1 | Test Merchant 1 | Safaricom Contract | + | Test Estate 1 | Test Merchant 1 | Hospital 1 Contract | + | Test Estate 1 | Test Merchant 1 | PataPawa PostPay Contract | + | Test Estate 1 | Test Merchant 2 | Safaricom Contract | + | Test Estate 1 | Test Merchant 2 | Hospital 1 Contract | + | Test Estate 1 | Test Merchant 2 | PataPawa PostPay Contract | + | Test Estate 1 | Test Merchant 3 | Safaricom Contract | + | Test Estate 1 | Test Merchant 3 | Hospital 1 Contract | + | Test Estate 1 | Test Merchant 3 | PataPawa PostPay Contract | + | Test Estate 1 | Test Merchant 4 | Safaricom Contract | + | Test Estate 1 | Test Merchant 4 | Hospital 1 Contract | + | Test Estate 1 | Test Merchant 4 | PataPawa PostPay Contract | + Given the following bills are available at the PataPawa PostPaid Host | AccountNumber | AccountName | DueDate | Amount | | 12345678 | Test Account 1 | Today | 100.00 | @@ -119,6 +134,34 @@ Scenario: Sale Transactions | Test Estate 1 | Test Merchant 1 | 8 | 0000 | SUCCESS | | Test Estate 1 | Test Merchant 1 | 9 | 0000 | SUCCESS | + Then the following entries appear in the merchants balance history for estate 'Test Estate 1' and merchant 'Test Merchant 1' + | DateTime | Reference | EntryType | In | Out | ChangeAmount | Balance | + | Today | Merchant Deposit | C | 240.00 | 0.00 | 240.00 | 230.00 | + | Today | Transaction Completed | D | 0.00 | 110.00 | 110.00 | 130.00 | + | Today | Transaction Completed | D | 0.00 | 90.00 | 90.00 | 30.00 | + | Today | Transaction Completed | D | 0.00 | 10.00 | 10.00 | 20.00 | + | Today | Transaction Completed | D | 0.00 | 20.00 | 20.00 | 20.00 | + | Today | Transaction Fee Processed | C | 0.00 | 0.55 | 0.55 | 20.00 | + | Today | Transaction Fee Processed | C | 0.00 | 0.45 | 0.45 | 20.00 | + | Today | Transaction Fee Processed | C | 0.00 | 0.01 | 0.10 | 20.00 | + | Today | Opening Balance | C | 0.00 | 0.00 | 0.00 | 20.00 | + + Then the following entries appear in the merchants balance history for estate 'Test Estate 1' and merchant 'Test Merchant 2' + | DateTime | Reference | EntryType | In | Out | ChangeAmount | Balance | + | Today | Merchant Deposit | C | 110.00 | 0.00 | 110.00 | 230.00 | + | Today | Transaction Completed | D | 0.00 | 100.00 | 100.00 | 130.00 | + | Today | Transaction Completed | D | 0.00 | 10.00 | 10.00 | 30.00 | + | Today | Transaction Fee Processed | C | 0.00 | 0.50 | 0.50 | 20.00 | + | Today | Opening Balance | C | 0.00 | 0.00 | 0.00 | 20.00 | + + Then the following entries appear in the merchants balance history for estate 'Test Estate 1' and merchant 'Test Merchant 3' + | DateTime | Reference | EntryType | In | Out | ChangeAmount | Balance | + | Today | Merchant Deposit | C | 110.00 | 0.00 | 110.00 | 230.00 | + | Today | Transaction Completed | D | 0.00 | 100.00 | 100.00 | 130.00 | + | Today | Transaction Completed | D | 0.00 | 10.00 | 10.00 | 30.00 | + | Today | Transaction Fee Processed | C | 0.00 | 0.85 | 0.50 | 20.00 | + | Today | Opening Balance | C | 0.00 | 0.00 | 0.00 | 20.00 | + When I request the receipt is resent | EstateName | MerchantName | TransactionNumber | | Test Estate 1 | Test Merchant 1 | 1 | @@ -187,30 +230,4 @@ Scenario: Sale Transactions | EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage | | Test Estate 1 | Test Merchant 4 | 17 | 1009 | Merchant [Test Merchant 4] does not have enough credit available [100.00] to perform transaction amount [300.00] | - Then the following entries appear in the merchants balance history for estate 'Test Estate 1' and merchant 'Test Merchant 1' - | DateTime | Reference | EntryType | In | Out | ChangeAmount | Balance | - | Today | Merchant Deposit | C | 240.00 | 0.00 | 240.00 | 230.00 | - | Today | Transaction Completed | D | 0.00 | 110.00 | 110.00 | 130.00 | - | Today | Transaction Completed | D | 0.00 | 90.00 | 90.00 | 30.00 | - | Today | Transaction Completed | D | 0.00 | 10.00 | 10.00 | 20.00 | - | Today | Transaction Completed | D | 0.00 | 20.00 | 20.00 | 20.00 | - | Today | Transaction Fee Processed | C | 0.00 | 0.55 | 0.55 | 20.00 | - | Today | Transaction Fee Processed | C | 0.00 | 0.45 | 0.45 | 20.00 | - | Today | Transaction Fee Processed | C | 0.00 | 0.01 | 0.10 | 20.00 | - | Today | Opening Balance | C | 0.00 | 0.00 | 0.00 | 20.00 | - - Then the following entries appear in the merchants balance history for estate 'Test Estate 1' and merchant 'Test Merchant 2' - | DateTime | Reference | EntryType | In | Out | ChangeAmount | Balance | - | Today | Merchant Deposit | C | 110.00 | 0.00 | 110.00 | 230.00 | - | Today | Transaction Completed | D | 0.00 | 100.00 | 100.00 | 130.00 | - | Today | Transaction Completed | D | 0.00 | 10.00 | 10.00 | 30.00 | - | Today | Transaction Fee Processed | C | 0.00 | 0.50 | 0.50 | 20.00 | - | Today | Opening Balance | C | 0.00 | 0.00 | 0.00 | 20.00 | - - Then the following entries appear in the merchants balance history for estate 'Test Estate 1' and merchant 'Test Merchant 3' - | DateTime | Reference | EntryType | In | Out | ChangeAmount | Balance | - | Today | Merchant Deposit | C | 110.00 | 0.00 | 110.00 | 230.00 | - | Today | Transaction Completed | D | 0.00 | 100.00 | 100.00 | 130.00 | - | Today | Transaction Completed | D | 0.00 | 10.00 | 10.00 | 30.00 | - | Today | Transaction Fee Processed | C | 0.00 | 0.85 | 0.50 | 20.00 | - | Today | Opening Balance | C | 0.00 | 0.00 | 0.00 | 20.00 | \ No newline at end of file + \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs b/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs index 44ced4a7..7ac0ac88 100644 --- a/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs @@ -83,135 +83,135 @@ public virtual void FeatureBackground() { #line 4 #line hidden - TechTalk.SpecFlow.Table table48 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table49 = new TechTalk.SpecFlow.Table(new string[] { "Name", "DisplayName", "Description"}); - table48.AddRow(new string[] { + table49.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table48.AddRow(new string[] { + table49.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); - table48.AddRow(new string[] { + table49.AddRow(new string[] { "voucherManagement", "Voucher Management REST Scope", "A scope for Voucher Management REST"}); - table48.AddRow(new string[] { + table49.AddRow(new string[] { "messagingService", "Scope for Messaging REST", "Scope for Messaging REST"}); #line 6 - testRunner.Given("I create the following api scopes", ((string)(null)), table48, "Given "); + testRunner.Given("I create the following api scopes", ((string)(null)), table49, "Given "); #line hidden - TechTalk.SpecFlow.Table table49 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table50 = new TechTalk.SpecFlow.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table49.AddRow(new string[] { + table50.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "MerchantId, EstateId, role"}); - table49.AddRow(new string[] { + table50.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", ""}); - table49.AddRow(new string[] { + table50.AddRow(new string[] { "voucherManagement", "Voucher Management REST", "Secret1", "voucherManagement", ""}); - table49.AddRow(new string[] { + table50.AddRow(new string[] { "messagingService", "Messaging REST", "Secret", "messagingService", ""}); #line 13 - testRunner.Given("the following api resources exist", ((string)(null)), table49, "Given "); + testRunner.Given("the following api resources exist", ((string)(null)), table50, "Given "); #line hidden - TechTalk.SpecFlow.Table table50 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table51 = new TechTalk.SpecFlow.Table(new string[] { "ClientId", "ClientName", "Secret", "Scopes", "GrantTypes"}); - table50.AddRow(new string[] { + table51.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", "estateManagement,transactionProcessor,voucherManagement,messagingService", "client_credentials"}); #line 20 - testRunner.Given("the following clients exist", ((string)(null)), table50, "Given "); + testRunner.Given("the following clients exist", ((string)(null)), table51, "Given "); #line hidden - TechTalk.SpecFlow.Table table51 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table52 = new TechTalk.SpecFlow.Table(new string[] { "ClientId"}); - table51.AddRow(new string[] { + table52.AddRow(new string[] { "serviceClient"}); #line 24 testRunner.Given("I have a token to access the estate management and transaction processor resource" + - "s", ((string)(null)), table51, "Given "); + "s", ((string)(null)), table52, "Given "); #line hidden - TechTalk.SpecFlow.Table table52 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table53 = new TechTalk.SpecFlow.Table(new string[] { "EstateName"}); - table52.AddRow(new string[] { + table53.AddRow(new string[] { "Test Estate 1"}); #line 28 - testRunner.Given("I have created the following estates", ((string)(null)), table52, "Given "); + testRunner.Given("I have created the following estates", ((string)(null)), table53, "Given "); #line hidden - TechTalk.SpecFlow.Table table53 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table54 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table53.AddRow(new string[] { + table54.AddRow(new string[] { "Test Estate 1", "Safaricom", "True", "True"}); - table53.AddRow(new string[] { + table54.AddRow(new string[] { "Test Estate 1", "Voucher", "True", "True"}); - table53.AddRow(new string[] { + table54.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "True", "True"}); #line 32 - testRunner.Given("I have created the following operators", ((string)(null)), table53, "Given "); + testRunner.Given("I have created the following operators", ((string)(null)), table54, "Given "); #line hidden - TechTalk.SpecFlow.Table table54 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table55 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "ContractDescription"}); - table54.AddRow(new string[] { + table55.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract"}); - table54.AddRow(new string[] { + table55.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract"}); - table54.AddRow(new string[] { + table55.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "PataPawa PostPay Contract"}); #line 38 - testRunner.Given("I create a contract with the following values", ((string)(null)), table54, "Given "); + testRunner.Given("I create a contract with the following values", ((string)(null)), table55, "Given "); #line hidden - TechTalk.SpecFlow.Table table55 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table56 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -219,7 +219,7 @@ public virtual void FeatureBackground() "DisplayText", "Value", "ProductType"}); - table55.AddRow(new string[] { + table56.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -227,7 +227,7 @@ public virtual void FeatureBackground() "Custom", "", "MobileTopup"}); - table55.AddRow(new string[] { + table56.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract", @@ -235,7 +235,7 @@ public virtual void FeatureBackground() "10 KES", "", "Voucher"}); - table55.AddRow(new string[] { + table56.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "PataPawa PostPay Contract", @@ -244,9 +244,9 @@ public virtual void FeatureBackground() "", "BillPayment"}); #line 44 - testRunner.When("I create the following Products", ((string)(null)), table55, "When "); + testRunner.When("I create the following Products", ((string)(null)), table56, "When "); #line hidden - TechTalk.SpecFlow.Table table56 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table57 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -254,7 +254,7 @@ public virtual void FeatureBackground() "CalculationType", "FeeDescription", "Value"}); - table56.AddRow(new string[] { + table57.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -262,7 +262,7 @@ public virtual void FeatureBackground() "Percentage", "Merchant Commission", "0.50"}); - table56.AddRow(new string[] { + table57.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "PataPawa PostPay Contract", @@ -271,9 +271,9 @@ public virtual void FeatureBackground() "Merchant Commission", "0.50"}); #line 50 - testRunner.When("I add the following Transaction Fees", ((string)(null)), table56, "When "); + testRunner.When("I add the following Transaction Fees", ((string)(null)), table57, "When "); #line hidden - TechTalk.SpecFlow.Table table57 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table58 = new TechTalk.SpecFlow.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -282,7 +282,7 @@ public virtual void FeatureBackground() "ContactName", "EmailAddress", "EstateName"}); - table57.AddRow(new string[] { + table58.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -291,7 +291,7 @@ public virtual void FeatureBackground() "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); - table57.AddRow(new string[] { + table58.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -300,7 +300,7 @@ public virtual void FeatureBackground() "Test Contact 2", "testcontact2@merchant2.co.uk", "Test Estate 1"}); - table57.AddRow(new string[] { + table58.AddRow(new string[] { "Test Merchant 3", "Address Line 1", "TestTown", @@ -309,7 +309,7 @@ public virtual void FeatureBackground() "Test Contact 3", "testcontact3@merchant3.co.uk", "Test Estate 1"}); - table57.AddRow(new string[] { + table58.AddRow(new string[] { "Test Merchant 4", "Address Line 1", "TestTown", @@ -319,157 +319,212 @@ public virtual void FeatureBackground() "testcontact4@merchant4.co.uk", "Test Estate 1"}); #line 55 - testRunner.Given("I create the following merchants", ((string)(null)), table57, "Given "); + testRunner.Given("I create the following merchants", ((string)(null)), table58, "Given "); #line hidden - TechTalk.SpecFlow.Table table58 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table59 = new TechTalk.SpecFlow.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Safaricom", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Voucher", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Safaricom", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Voucher", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Safaricom", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Voucher", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Safaricom", "Test Merchant 4", "00000004", "10000004", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "Voucher", "Test Merchant 4", "00000004", "10000004", "Test Estate 1"}); - table58.AddRow(new string[] { + table59.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 4", "00000004", "10000004", "Test Estate 1"}); #line 62 - testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table58, "Given "); + testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table59, "Given "); #line hidden - TechTalk.SpecFlow.Table table59 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table60 = new TechTalk.SpecFlow.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table59.AddRow(new string[] { + table60.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); - table59.AddRow(new string[] { + table60.AddRow(new string[] { "123456781", "Test Merchant 2", "Test Estate 1"}); - table59.AddRow(new string[] { + table60.AddRow(new string[] { "123456782", "Test Merchant 3", "Test Estate 1"}); - table59.AddRow(new string[] { + table60.AddRow(new string[] { "123456783", "Test Merchant 4", "Test Estate 1"}); #line 77 - testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table59, "Given "); + testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table60, "Given "); #line hidden - TechTalk.SpecFlow.Table table60 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table61 = new TechTalk.SpecFlow.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table60.AddRow(new string[] { + table61.AddRow(new string[] { "Deposit1", "240.00", "Today", "Test Merchant 1", "Test Estate 1"}); - table60.AddRow(new string[] { + table61.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 2", "Test Estate 1"}); - table60.AddRow(new string[] { + table61.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 3", "Test Estate 1"}); - table60.AddRow(new string[] { + table61.AddRow(new string[] { "Deposit1", "100.00", "Today", "Test Merchant 4", "Test Estate 1"}); #line 84 - testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table60, "Given "); + testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table61, "Given "); #line hidden - TechTalk.SpecFlow.Table table61 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table62 = new TechTalk.SpecFlow.Table(new string[] { + "EstateName", + "MerchantName", + "ContractDescription"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "Safaricom Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "Hospital 1 Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "PataPawa PostPay Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 2", + "Safaricom Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 2", + "Hospital 1 Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 2", + "PataPawa PostPay Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 3", + "Safaricom Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 3", + "Hospital 1 Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 3", + "PataPawa PostPay Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 4", + "Safaricom Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 4", + "Hospital 1 Contract"}); + table62.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 4", + "PataPawa PostPay Contract"}); +#line 91 + testRunner.When("I add the following contracts to the following merchants", ((string)(null)), table62, "When "); +#line hidden + TechTalk.SpecFlow.Table table63 = new TechTalk.SpecFlow.Table(new string[] { "AccountNumber", "AccountName", "DueDate", "Amount"}); - table61.AddRow(new string[] { + table63.AddRow(new string[] { "12345678", "Test Account 1", "Today", "100.00"}); -#line 91 - testRunner.Given("the following bills are available at the PataPawa PostPaid Host", ((string)(null)), table61, "Given "); +#line 106 + testRunner.Given("the following bills are available at the PataPawa PostPaid Host", ((string)(null)), table63, "Given "); #line hidden } @@ -488,7 +543,7 @@ public void SaleTransactions() "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transactions", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 96 +#line 111 this.ScenarioInitialize(scenarioInfo); #line hidden if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) @@ -501,7 +556,7 @@ public void SaleTransactions() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table62 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table64 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -520,7 +575,7 @@ public void SaleTransactions() "MessageType", "AccountNumber", "CustomerName"}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "1", "Sale", @@ -539,7 +594,7 @@ public void SaleTransactions() "", "", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "2", "Sale", @@ -558,7 +613,7 @@ public void SaleTransactions() "", "", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "3", "Sale", @@ -577,7 +632,7 @@ public void SaleTransactions() "", "", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "4", "Sale", @@ -596,7 +651,7 @@ public void SaleTransactions() "", "", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "5", "Sale", @@ -615,7 +670,7 @@ public void SaleTransactions() "", "", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "6", "Sale", @@ -634,7 +689,7 @@ public void SaleTransactions() "", "", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "7", "Sale", @@ -653,7 +708,7 @@ public void SaleTransactions() "", "", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "8", "Sale", @@ -672,7 +727,7 @@ public void SaleTransactions() "VerifyAccount", "12345678", ""}); - table62.AddRow(new string[] { + table64.AddRow(new string[] { "Today", "9", "Sale", @@ -691,147 +746,335 @@ public void SaleTransactions() "ProcessBill", "12345678", "Mr Test Customer"}); -#line 98 - testRunner.When("I perform the following transactions", ((string)(null)), table62, "When "); +#line 113 + testRunner.When("I perform the following transactions", ((string)(null)), table64, "When "); #line hidden - TechTalk.SpecFlow.Table table63 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table65 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "2", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "3", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "4", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "5", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "6", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "7", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "8", "0000", "SUCCESS"}); - table63.AddRow(new string[] { + table65.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "9", "0000", "SUCCESS"}); -#line 110 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table63, "Then "); -#line hidden - TechTalk.SpecFlow.Table table64 = new TechTalk.SpecFlow.Table(new string[] { - "EstateName", - "MerchantName", - "TransactionNumber"}); - table64.AddRow(new string[] { - "Test Estate 1", - "Test Merchant 1", - "1"}); -#line 122 - testRunner.When("I request the receipt is resent", ((string)(null)), table64, "When "); +#line 125 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table65, "Then "); #line hidden - TechTalk.SpecFlow.Table table65 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table66 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", - "TransactionNumber", - "TransactionType", - "TransactionSource", - "MerchantName", - "DeviceIdentifier", - "EstateName", - "OperatorName", - "TransactionAmount", - "CustomerAccountNumber", - "CustomerEmailAddress", - "ContractDescription", - "ProductName"}); - table65.AddRow(new string[] { + "Reference", + "EntryType", + "In", + "Out", + "ChangeAmount", + "Balance"}); + table66.AddRow(new string[] { "Today", - "10", - "Sale", - "1", - "Test Merchant 1", - "123456781", - "Test Estate 1", - "Safaricom", - "100.00", - "123456789", - "testcustomer@customer.co.uk", - "Safaricom Contract", - "Variable Topup"}); -#line 126 - testRunner.When("I perform the following transactions", ((string)(null)), table65, "When "); -#line hidden - TechTalk.SpecFlow.Table table66 = new TechTalk.SpecFlow.Table(new string[] { - "EstateName", - "MerchantName", - "TransactionNumber", - "ResponseCode", - "ResponseMessage"}); + "Merchant Deposit", + "C", + "240.00", + "0.00", + "240.00", + "230.00"}); table66.AddRow(new string[] { - "Test Estate 1", - "Test Merchant 1", - "10", - "1000", - "Device Identifier 123456781 not valid for Merchant Test Merchant 1"}); -#line 130 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table66, "Then "); -#line hidden - TechTalk.SpecFlow.Table table67 = new TechTalk.SpecFlow.Table(new string[] { - "DateTime", - "TransactionNumber", - "TransactionType", - "TransactionSource", - "MerchantName", - "DeviceIdentifier", - "EstateName", - "OperatorName", - "TransactionAmount", - "CustomerAccountNumber", - "CustomerEmailAddress", - "ContractDescription", - "ProductName"}); - table67.AddRow(new string[] { "Today", - "11", - "Sale", + "Transaction Completed", + "D", + "0.00", + "110.00", + "110.00", + "130.00"}); + table66.AddRow(new string[] { + "Today", + "Transaction Completed", + "D", + "0.00", + "90.00", + "90.00", + "30.00"}); + table66.AddRow(new string[] { + "Today", + "Transaction Completed", + "D", + "0.00", + "10.00", + "10.00", + "20.00"}); + table66.AddRow(new string[] { + "Today", + "Transaction Completed", + "D", + "0.00", + "20.00", + "20.00", + "20.00"}); + table66.AddRow(new string[] { + "Today", + "Transaction Fee Processed", + "C", + "0.00", + "0.55", + "0.55", + "20.00"}); + table66.AddRow(new string[] { + "Today", + "Transaction Fee Processed", + "C", + "0.00", + "0.45", + "0.45", + "20.00"}); + table66.AddRow(new string[] { + "Today", + "Transaction Fee Processed", + "C", + "0.00", + "0.01", + "0.10", + "20.00"}); + table66.AddRow(new string[] { + "Today", + "Opening Balance", + "C", + "0.00", + "0.00", + "0.00", + "20.00"}); +#line 137 + testRunner.Then("the following entries appear in the merchants balance history for estate \'Test Es" + + "tate 1\' and merchant \'Test Merchant 1\'", ((string)(null)), table66, "Then "); +#line hidden + TechTalk.SpecFlow.Table table67 = new TechTalk.SpecFlow.Table(new string[] { + "DateTime", + "Reference", + "EntryType", + "In", + "Out", + "ChangeAmount", + "Balance"}); + table67.AddRow(new string[] { + "Today", + "Merchant Deposit", + "C", + "110.00", + "0.00", + "110.00", + "230.00"}); + table67.AddRow(new string[] { + "Today", + "Transaction Completed", + "D", + "0.00", + "100.00", + "100.00", + "130.00"}); + table67.AddRow(new string[] { + "Today", + "Transaction Completed", + "D", + "0.00", + "10.00", + "10.00", + "30.00"}); + table67.AddRow(new string[] { + "Today", + "Transaction Fee Processed", + "C", + "0.00", + "0.50", + "0.50", + "20.00"}); + table67.AddRow(new string[] { + "Today", + "Opening Balance", + "C", + "0.00", + "0.00", + "0.00", + "20.00"}); +#line 149 + testRunner.Then("the following entries appear in the merchants balance history for estate \'Test Es" + + "tate 1\' and merchant \'Test Merchant 2\'", ((string)(null)), table67, "Then "); +#line hidden + TechTalk.SpecFlow.Table table68 = new TechTalk.SpecFlow.Table(new string[] { + "DateTime", + "Reference", + "EntryType", + "In", + "Out", + "ChangeAmount", + "Balance"}); + table68.AddRow(new string[] { + "Today", + "Merchant Deposit", + "C", + "110.00", + "0.00", + "110.00", + "230.00"}); + table68.AddRow(new string[] { + "Today", + "Transaction Completed", + "D", + "0.00", + "100.00", + "100.00", + "130.00"}); + table68.AddRow(new string[] { + "Today", + "Transaction Completed", + "D", + "0.00", + "10.00", + "10.00", + "30.00"}); + table68.AddRow(new string[] { + "Today", + "Transaction Fee Processed", + "C", + "0.00", + "0.85", + "0.50", + "20.00"}); + table68.AddRow(new string[] { + "Today", + "Opening Balance", + "C", + "0.00", + "0.00", + "0.00", + "20.00"}); +#line 157 + testRunner.Then("the following entries appear in the merchants balance history for estate \'Test Es" + + "tate 1\' and merchant \'Test Merchant 3\'", ((string)(null)), table68, "Then "); +#line hidden + TechTalk.SpecFlow.Table table69 = new TechTalk.SpecFlow.Table(new string[] { + "EstateName", + "MerchantName", + "TransactionNumber"}); + table69.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "1"}); +#line 165 + testRunner.When("I request the receipt is resent", ((string)(null)), table69, "When "); +#line hidden + TechTalk.SpecFlow.Table table70 = new TechTalk.SpecFlow.Table(new string[] { + "DateTime", + "TransactionNumber", + "TransactionType", + "TransactionSource", + "MerchantName", + "DeviceIdentifier", + "EstateName", + "OperatorName", + "TransactionAmount", + "CustomerAccountNumber", + "CustomerEmailAddress", + "ContractDescription", + "ProductName"}); + table70.AddRow(new string[] { + "Today", + "10", + "Sale", + "1", + "Test Merchant 1", + "123456781", + "Test Estate 1", + "Safaricom", + "100.00", + "123456789", + "testcustomer@customer.co.uk", + "Safaricom Contract", + "Variable Topup"}); +#line 169 + testRunner.When("I perform the following transactions", ((string)(null)), table70, "When "); +#line hidden + TechTalk.SpecFlow.Table table71 = new TechTalk.SpecFlow.Table(new string[] { + "EstateName", + "MerchantName", + "TransactionNumber", + "ResponseCode", + "ResponseMessage"}); + table71.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "10", + "1000", + "Device Identifier 123456781 not valid for Merchant Test Merchant 1"}); +#line 173 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table71, "Then "); +#line hidden + TechTalk.SpecFlow.Table table72 = new TechTalk.SpecFlow.Table(new string[] { + "DateTime", + "TransactionNumber", + "TransactionType", + "TransactionSource", + "MerchantName", + "DeviceIdentifier", + "EstateName", + "OperatorName", + "TransactionAmount", + "CustomerAccountNumber", + "CustomerEmailAddress", + "ContractDescription", + "ProductName"}); + table72.AddRow(new string[] { + "Today", + "11", + "Sale", "1", "Test Merchant 1", "123456780", @@ -842,25 +1085,25 @@ public void SaleTransactions() "testcustomer@customer.co.uk", "Safaricom Contract", "Variable Topup"}); -#line 134 - testRunner.When("I perform the following transactions", ((string)(null)), table67, "When "); +#line 177 + testRunner.When("I perform the following transactions", ((string)(null)), table72, "When "); #line hidden - TechTalk.SpecFlow.Table table68 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table73 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table68.AddRow(new string[] { + table73.AddRow(new string[] { "InvalidEstate", "Test Merchant 1", "11", "1001", "Estate Id [79902550-64df-4491-b0c1-4e78943928a3] is not a valid estate"}); -#line 138 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table68, "Then "); +#line 181 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table73, "Then "); #line hidden - TechTalk.SpecFlow.Table table69 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table74 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -874,7 +1117,7 @@ public void SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table69.AddRow(new string[] { + table74.AddRow(new string[] { "Today", "12", "Sale", @@ -888,26 +1131,26 @@ public void SaleTransactions() "testcustomer@customer.co.uk", "Safaricom Contract", "Variable Topup"}); -#line 142 - testRunner.When("I perform the following transactions", ((string)(null)), table69, "When "); +#line 185 + testRunner.When("I perform the following transactions", ((string)(null)), table74, "When "); #line hidden - TechTalk.SpecFlow.Table table70 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table75 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table70.AddRow(new string[] { + table75.AddRow(new string[] { "Test Estate 1", "InvalidMerchant", "12", "1002", "Merchant Id [d59320fa-4c3e-4900-a999-483f6a10c69a] is not a valid merchant for es" + "tate [Test Estate 1]"}); -#line 146 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table70, "Then "); +#line 189 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table75, "Then "); #line hidden - TechTalk.SpecFlow.Table table71 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table76 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -921,7 +1164,7 @@ public void SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table71.AddRow(new string[] { + table76.AddRow(new string[] { "Today", "13", "Sale", @@ -935,26 +1178,26 @@ public void SaleTransactions() "testcustomer@customer.co.uk", "EmptyContract", "Variable Topup"}); -#line 150 - testRunner.When("I perform the following transactions", ((string)(null)), table71, "When "); +#line 193 + testRunner.When("I perform the following transactions", ((string)(null)), table76, "When "); #line hidden - TechTalk.SpecFlow.Table table72 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table77 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table72.AddRow(new string[] { + table77.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "13", "1012", "Contract Id [00000000-0000-0000-0000-000000000000] must be set for a sale transac" + "tion"}); -#line 154 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table72, "Then "); +#line 197 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table77, "Then "); #line hidden - TechTalk.SpecFlow.Table table73 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table78 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -968,7 +1211,7 @@ public void SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table73.AddRow(new string[] { + table78.AddRow(new string[] { "Today", "14", "Sale", @@ -982,26 +1225,26 @@ public void SaleTransactions() "testcustomer@customer.co.uk", "InvalidContract", "Variable Topup"}); -#line 158 - testRunner.When("I perform the following transactions", ((string)(null)), table73, "When "); +#line 201 + testRunner.When("I perform the following transactions", ((string)(null)), table78, "When "); #line hidden - TechTalk.SpecFlow.Table table74 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table79 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table74.AddRow(new string[] { + table79.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "14", "1015", "Contract Id [934d8164-f36a-448e-b27b-4d671d41d180] not valid for Merchant [Test M" + "erchant 1]"}); -#line 162 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table74, "Then "); +#line 205 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table79, "Then "); #line hidden - TechTalk.SpecFlow.Table table75 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table80 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1015,7 +1258,7 @@ public void SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table75.AddRow(new string[] { + table80.AddRow(new string[] { "Today", "15", "Sale", @@ -1029,26 +1272,26 @@ public void SaleTransactions() "testcustomer@customer.co.uk", "Safaricom Contract", "EmptyProduct"}); -#line 166 - testRunner.When("I perform the following transactions", ((string)(null)), table75, "When "); +#line 209 + testRunner.When("I perform the following transactions", ((string)(null)), table80, "When "); #line hidden - TechTalk.SpecFlow.Table table76 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table81 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table76.AddRow(new string[] { + table81.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "15", "1013", "Product Id [00000000-0000-0000-0000-000000000000] must be set for a sale transact" + "ion"}); -#line 170 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table76, "Then "); +#line 213 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table81, "Then "); #line hidden - TechTalk.SpecFlow.Table table77 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table82 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1062,7 +1305,7 @@ public void SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table77.AddRow(new string[] { + table82.AddRow(new string[] { "Today", "16", "Sale", @@ -1076,26 +1319,26 @@ public void SaleTransactions() "testcustomer@customer.co.uk", "Safaricom Contract", "InvalidProduct"}); -#line 174 - testRunner.When("I perform the following transactions", ((string)(null)), table77, "When "); +#line 217 + testRunner.When("I perform the following transactions", ((string)(null)), table82, "When "); #line hidden - TechTalk.SpecFlow.Table table78 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table83 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table78.AddRow(new string[] { + table83.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "16", "1016", "Product Id [934d8164-f36a-448e-b27b-4d671d41d180] not valid for Merchant [Test Me" + "rchant 1]"}); -#line 178 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table78, "Then "); +#line 221 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table83, "Then "); #line hidden - TechTalk.SpecFlow.Table table79 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table84 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1109,7 +1352,7 @@ public void SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table79.AddRow(new string[] { + table84.AddRow(new string[] { "Today", "17", "Sale", @@ -1123,212 +1366,24 @@ public void SaleTransactions() "testcustomer@customer.co.uk", "Safaricom Contract", "Variable Topup"}); -#line 182 - testRunner.When("I perform the following transactions", ((string)(null)), table79, "When "); +#line 225 + testRunner.When("I perform the following transactions", ((string)(null)), table84, "When "); #line hidden - TechTalk.SpecFlow.Table table80 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table85 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table80.AddRow(new string[] { + table85.AddRow(new string[] { "Test Estate 1", "Test Merchant 4", "17", "1009", "Merchant [Test Merchant 4] does not have enough credit available [100.00] to perf" + "orm transaction amount [300.00]"}); -#line 186 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table80, "Then "); -#line hidden - TechTalk.SpecFlow.Table table81 = new TechTalk.SpecFlow.Table(new string[] { - "DateTime", - "Reference", - "EntryType", - "In", - "Out", - "ChangeAmount", - "Balance"}); - table81.AddRow(new string[] { - "Today", - "Merchant Deposit", - "C", - "240.00", - "0.00", - "240.00", - "230.00"}); - table81.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "110.00", - "110.00", - "130.00"}); - table81.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "90.00", - "90.00", - "30.00"}); - table81.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "10.00", - "10.00", - "20.00"}); - table81.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "20.00", - "20.00", - "20.00"}); - table81.AddRow(new string[] { - "Today", - "Transaction Fee Processed", - "C", - "0.00", - "0.55", - "0.55", - "20.00"}); - table81.AddRow(new string[] { - "Today", - "Transaction Fee Processed", - "C", - "0.00", - "0.45", - "0.45", - "20.00"}); - table81.AddRow(new string[] { - "Today", - "Transaction Fee Processed", - "C", - "0.00", - "0.01", - "0.10", - "20.00"}); - table81.AddRow(new string[] { - "Today", - "Opening Balance", - "C", - "0.00", - "0.00", - "0.00", - "20.00"}); -#line 190 - testRunner.Then("the following entries appear in the merchants balance history for estate \'Test Es" + - "tate 1\' and merchant \'Test Merchant 1\'", ((string)(null)), table81, "Then "); -#line hidden - TechTalk.SpecFlow.Table table82 = new TechTalk.SpecFlow.Table(new string[] { - "DateTime", - "Reference", - "EntryType", - "In", - "Out", - "ChangeAmount", - "Balance"}); - table82.AddRow(new string[] { - "Today", - "Merchant Deposit", - "C", - "110.00", - "0.00", - "110.00", - "230.00"}); - table82.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "100.00", - "100.00", - "130.00"}); - table82.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "10.00", - "10.00", - "30.00"}); - table82.AddRow(new string[] { - "Today", - "Transaction Fee Processed", - "C", - "0.00", - "0.50", - "0.50", - "20.00"}); - table82.AddRow(new string[] { - "Today", - "Opening Balance", - "C", - "0.00", - "0.00", - "0.00", - "20.00"}); -#line 202 - testRunner.Then("the following entries appear in the merchants balance history for estate \'Test Es" + - "tate 1\' and merchant \'Test Merchant 2\'", ((string)(null)), table82, "Then "); -#line hidden - TechTalk.SpecFlow.Table table83 = new TechTalk.SpecFlow.Table(new string[] { - "DateTime", - "Reference", - "EntryType", - "In", - "Out", - "ChangeAmount", - "Balance"}); - table83.AddRow(new string[] { - "Today", - "Merchant Deposit", - "C", - "110.00", - "0.00", - "110.00", - "230.00"}); - table83.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "100.00", - "100.00", - "130.00"}); - table83.AddRow(new string[] { - "Today", - "Transaction Completed", - "D", - "0.00", - "10.00", - "10.00", - "30.00"}); - table83.AddRow(new string[] { - "Today", - "Transaction Fee Processed", - "C", - "0.00", - "0.85", - "0.50", - "20.00"}); - table83.AddRow(new string[] { - "Today", - "Opening Balance", - "C", - "0.00", - "0.00", - "0.00", - "20.00"}); -#line 210 - testRunner.Then("the following entries appear in the merchants balance history for estate \'Test Es" + - "tate 1\' and merchant \'Test Merchant 3\'", ((string)(null)), table83, "Then "); +#line 229 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table85, "Then "); #line hidden } this.ScenarioCleanup(); diff --git a/TransactionProcessor.IntegrationTests/Features/Settlement.feature b/TransactionProcessor.IntegrationTests/Features/Settlement.feature index 5225bd0c..3a681a9e 100644 --- a/TransactionProcessor.IntegrationTests/Features/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Features/Settlement.feature @@ -74,6 +74,15 @@ Scenario: Get Pending Settlement | Deposit1 | 110.00 | Today | Test Merchant 2 | Test Estate 1 | | Deposit1 | 120.00 | Today | Test Merchant 3 | Test Estate 1 | + When I add the following contracts to the following merchants + | EstateName | MerchantName | ContractDescription | + | Test Estate 1 | Test Merchant 1 | Safaricom Contract | + | Test Estate 1 | Test Merchant 1 | Hospital 1 Contract | + | Test Estate 1 | Test Merchant 2 | Safaricom Contract | + | Test Estate 1 | Test Merchant 2 | Hospital 1 Contract | + | Test Estate 1 | Test Merchant 3 | Safaricom Contract | + | Test Estate 1 | Test Merchant 3 | Hospital 1 Contract | + When I perform the following transactions | DateTime | TransactionNumber | TransactionType | TransactionSource | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName | RecipientEmail | RecipientMobile | | 2022-01-06 | 1 | Sale | 1 | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | @@ -124,6 +133,13 @@ Scenario: Process Settlement | 123456780 | Test Merchant 1 | Test Estate 1 | | 123456781 | Test Merchant 2 | Test Estate 1 | + When I add the following contracts to the following merchants + | EstateName | MerchantName | ContractDescription | + | Test Estate 1 | Test Merchant 1 | Safaricom Contract | + | Test Estate 1 | Test Merchant 1 | Hospital 1 Contract | + | Test Estate 1 | Test Merchant 2 | Safaricom Contract | + | Test Estate 1 | Test Merchant 2 | Hospital 1 Contract | + Given I make the following manual merchant deposits | Reference | Amount | DateTime | MerchantName | EstateName | | Deposit1 | 210.00 | Today | Test Merchant 1 | Test Estate 1 | diff --git a/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs index adbb5945..3a388373 100644 --- a/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs @@ -83,116 +83,116 @@ public virtual void FeatureBackground() { #line 4 #line hidden - TechTalk.SpecFlow.Table table84 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table86 = new TechTalk.SpecFlow.Table(new string[] { "Name", "DisplayName", "Description"}); - table84.AddRow(new string[] { + table86.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table84.AddRow(new string[] { + table86.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); - table84.AddRow(new string[] { + table86.AddRow(new string[] { "voucherManagement", "Voucher Management REST Scope", "A scope for Voucher Management REST"}); #line 6 - testRunner.Given("I create the following api scopes", ((string)(null)), table84, "Given "); + testRunner.Given("I create the following api scopes", ((string)(null)), table86, "Given "); #line hidden - TechTalk.SpecFlow.Table table85 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table87 = new TechTalk.SpecFlow.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table85.AddRow(new string[] { + table87.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "MerchantId, EstateId, role"}); - table85.AddRow(new string[] { + table87.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", ""}); - table85.AddRow(new string[] { + table87.AddRow(new string[] { "voucherManagement", "Voucher Management REST", "Secret1", "voucherManagement", ""}); #line 12 - testRunner.Given("the following api resources exist", ((string)(null)), table85, "Given "); + testRunner.Given("the following api resources exist", ((string)(null)), table87, "Given "); #line hidden - TechTalk.SpecFlow.Table table86 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table88 = new TechTalk.SpecFlow.Table(new string[] { "ClientId", "ClientName", "Secret", "Scopes", "GrantTypes"}); - table86.AddRow(new string[] { + table88.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", "estateManagement,transactionProcessor,voucherManagement", "client_credentials"}); #line 18 - testRunner.Given("the following clients exist", ((string)(null)), table86, "Given "); + testRunner.Given("the following clients exist", ((string)(null)), table88, "Given "); #line hidden - TechTalk.SpecFlow.Table table87 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table89 = new TechTalk.SpecFlow.Table(new string[] { "ClientId"}); - table87.AddRow(new string[] { + table89.AddRow(new string[] { "serviceClient"}); #line 22 testRunner.Given("I have a token to access the estate management and transaction processor resource" + - "s", ((string)(null)), table87, "Given "); + "s", ((string)(null)), table89, "Given "); #line hidden - TechTalk.SpecFlow.Table table88 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table90 = new TechTalk.SpecFlow.Table(new string[] { "EstateName"}); - table88.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1"}); #line 26 - testRunner.Given("I have created the following estates", ((string)(null)), table88, "Given "); + testRunner.Given("I have created the following estates", ((string)(null)), table90, "Given "); #line hidden - TechTalk.SpecFlow.Table table89 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table91 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table89.AddRow(new string[] { + table91.AddRow(new string[] { "Test Estate 1", "Safaricom", "True", "True"}); - table89.AddRow(new string[] { + table91.AddRow(new string[] { "Test Estate 1", "Voucher", "True", "True"}); #line 30 - testRunner.Given("I have created the following operators", ((string)(null)), table89, "Given "); + testRunner.Given("I have created the following operators", ((string)(null)), table91, "Given "); #line hidden - TechTalk.SpecFlow.Table table90 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table92 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "ContractDescription"}); - table90.AddRow(new string[] { + table92.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract"}); - table90.AddRow(new string[] { + table92.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract"}); #line 35 - testRunner.Given("I create a contract with the following values", ((string)(null)), table90, "Given "); + testRunner.Given("I create a contract with the following values", ((string)(null)), table92, "Given "); #line hidden - TechTalk.SpecFlow.Table table91 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table93 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -200,7 +200,7 @@ public virtual void FeatureBackground() "DisplayText", "Value", "ProductType"}); - table91.AddRow(new string[] { + table93.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -208,7 +208,7 @@ public virtual void FeatureBackground() "Custom", "", "MobileTopup"}); - table91.AddRow(new string[] { + table93.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract", @@ -217,9 +217,9 @@ public virtual void FeatureBackground() "", "Voucher"}); #line 40 - testRunner.When("I create the following Products", ((string)(null)), table91, "When "); + testRunner.When("I create the following Products", ((string)(null)), table93, "When "); #line hidden - TechTalk.SpecFlow.Table table92 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table94 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -227,7 +227,7 @@ public virtual void FeatureBackground() "CalculationType", "FeeDescription", "Value"}); - table92.AddRow(new string[] { + table94.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -236,7 +236,7 @@ public virtual void FeatureBackground() "Merchant Commission", "2.50"}); #line 45 - testRunner.When("I add the following Transaction Fees", ((string)(null)), table92, "When "); + testRunner.When("I add the following Transaction Fees", ((string)(null)), table94, "When "); #line hidden } @@ -266,7 +266,7 @@ public void GetPendingSettlement() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table93 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table95 = new TechTalk.SpecFlow.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -276,7 +276,7 @@ public void GetPendingSettlement() "EmailAddress", "EstateName", "SettlementSchedule"}); - table93.AddRow(new string[] { + table95.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -286,7 +286,7 @@ public void GetPendingSettlement() "testcontact1@merchant1.co.uk", "Test Estate 1", "Immediate"}); - table93.AddRow(new string[] { + table95.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -296,7 +296,7 @@ public void GetPendingSettlement() "testcontact2@merchant2.co.uk", "Test Estate 1", "Weekly"}); - table93.AddRow(new string[] { + table95.AddRow(new string[] { "Test Merchant 3", "Address Line 1", "TestTown", @@ -307,100 +307,131 @@ public void GetPendingSettlement() "Test Estate 1", "Monthly"}); #line 50 - testRunner.Given("I create the following merchants", ((string)(null)), table93, "Given "); + testRunner.Given("I create the following merchants", ((string)(null)), table95, "Given "); #line hidden - TechTalk.SpecFlow.Table table94 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table96 = new TechTalk.SpecFlow.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table94.AddRow(new string[] { + table96.AddRow(new string[] { "Safaricom", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table94.AddRow(new string[] { + table96.AddRow(new string[] { "Voucher", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table94.AddRow(new string[] { + table96.AddRow(new string[] { "Safaricom", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table94.AddRow(new string[] { + table96.AddRow(new string[] { "Voucher", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table94.AddRow(new string[] { + table96.AddRow(new string[] { "Safaricom", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table94.AddRow(new string[] { + table96.AddRow(new string[] { "Voucher", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); #line 56 - testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table94, "Given "); + testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table96, "Given "); #line hidden - TechTalk.SpecFlow.Table table95 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table97 = new TechTalk.SpecFlow.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table95.AddRow(new string[] { + table97.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); - table95.AddRow(new string[] { + table97.AddRow(new string[] { "123456781", "Test Merchant 2", "Test Estate 1"}); - table95.AddRow(new string[] { + table97.AddRow(new string[] { "123456782", "Test Merchant 3", "Test Estate 1"}); #line 65 - testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table95, "Given "); + testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table97, "Given "); #line hidden - TechTalk.SpecFlow.Table table96 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table98 = new TechTalk.SpecFlow.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table96.AddRow(new string[] { + table98.AddRow(new string[] { "Deposit1", "210.00", "Today", "Test Merchant 1", "Test Estate 1"}); - table96.AddRow(new string[] { + table98.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 2", "Test Estate 1"}); - table96.AddRow(new string[] { + table98.AddRow(new string[] { "Deposit1", "120.00", "Today", "Test Merchant 3", "Test Estate 1"}); #line 71 - testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table96, "Given "); + testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table98, "Given "); #line hidden - TechTalk.SpecFlow.Table table97 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table99 = new TechTalk.SpecFlow.Table(new string[] { + "EstateName", + "MerchantName", + "ContractDescription"}); + table99.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "Safaricom Contract"}); + table99.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "Hospital 1 Contract"}); + table99.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 2", + "Safaricom Contract"}); + table99.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 2", + "Hospital 1 Contract"}); + table99.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 3", + "Safaricom Contract"}); + table99.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 3", + "Hospital 1 Contract"}); +#line 77 + testRunner.When("I add the following contracts to the following merchants", ((string)(null)), table99, "When "); +#line hidden + TechTalk.SpecFlow.Table table100 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -416,7 +447,7 @@ public void GetPendingSettlement() "ProductName", "RecipientEmail", "RecipientMobile"}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "1", "Sale", @@ -432,7 +463,7 @@ public void GetPendingSettlement() "Variable Topup", "", ""}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "2", "Sale", @@ -448,7 +479,7 @@ public void GetPendingSettlement() "Variable Topup", "", ""}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "3", "Sale", @@ -464,7 +495,7 @@ public void GetPendingSettlement() "Variable Topup", "", ""}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "4", "Sale", @@ -480,7 +511,7 @@ public void GetPendingSettlement() "Variable Topup", "", ""}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "5", "Sale", @@ -496,7 +527,7 @@ public void GetPendingSettlement() "10 KES", "test@recipient.co.uk", ""}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "6", "Sale", @@ -512,7 +543,7 @@ public void GetPendingSettlement() "10 KES", "", "123456789"}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "7", "Sale", @@ -528,7 +559,7 @@ public void GetPendingSettlement() "10 KES", "test@recipient.co.uk", ""}); - table97.AddRow(new string[] { + table100.AddRow(new string[] { "2022-01-06", "8", "Sale", @@ -544,96 +575,96 @@ public void GetPendingSettlement() "10 KES", "test@recipient.co.uk", ""}); -#line 77 - testRunner.When("I perform the following transactions", ((string)(null)), table97, "When "); +#line 86 + testRunner.When("I perform the following transactions", ((string)(null)), table100, "When "); #line hidden - TechTalk.SpecFlow.Table table98 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table101 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1", "0000", "SUCCESS"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "2", "0000", "SUCCESS"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "3", "0000", "SUCCESS"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "4", "0000", "SUCCESS"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "5", "0000", "SUCCESS"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "6", "0000", "SUCCESS"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "7", "0000", "SUCCESS"}); - table98.AddRow(new string[] { + table101.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "8", "0000", "SUCCESS"}); -#line 88 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table98, "Then "); +#line 97 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table101, "Then "); #line hidden - TechTalk.SpecFlow.Table table99 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table102 = new TechTalk.SpecFlow.Table(new string[] { "SettlementDate", "EstateName", "MerchantName", "NumberOfFees"}); - table99.AddRow(new string[] { + table102.AddRow(new string[] { "2022-01-13", "Test Estate 1", "Test Merchant 2", "1"}); - table99.AddRow(new string[] { + table102.AddRow(new string[] { "2022-02-06", "Test Estate 1", "Test Merchant 3", "1"}); -#line 99 - testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table99, "When "); +#line 108 + testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table102, "When "); #line hidden - TechTalk.SpecFlow.Table table100 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table103 = new TechTalk.SpecFlow.Table(new string[] { "SettlementDate", "EstateName", "MerchantName", "NumberOfFees"}); - table100.AddRow(new string[] { + table103.AddRow(new string[] { "2022-01-06", "Test Estate 1", "Test Merchant 1", "2"}); -#line 104 - testRunner.When("I get the completed settlements the following information should be returned", ((string)(null)), table100, "When "); +#line 113 + testRunner.When("I get the completed settlements the following information should be returned", ((string)(null)), table103, "When "); #line hidden } this.ScenarioCleanup(); @@ -649,7 +680,7 @@ public void ProcessSettlement() "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Process Settlement", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 109 +#line 118 this.ScenarioInitialize(scenarioInfo); #line hidden if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) @@ -662,7 +693,7 @@ public void ProcessSettlement() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table101 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table104 = new TechTalk.SpecFlow.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -672,7 +703,7 @@ public void ProcessSettlement() "EmailAddress", "EstateName", "SettlementSchedule"}); - table101.AddRow(new string[] { + table104.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -682,7 +713,7 @@ public void ProcessSettlement() "testcontact1@merchant1.co.uk", "Test Estate 1", "Immediate"}); - table101.AddRow(new string[] { + table104.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -692,79 +723,102 @@ public void ProcessSettlement() "testcontact2@merchant2.co.uk", "Test Estate 1", "Weekly"}); -#line 110 - testRunner.Given("I create the following merchants", ((string)(null)), table101, "Given "); +#line 119 + testRunner.Given("I create the following merchants", ((string)(null)), table104, "Given "); #line hidden - TechTalk.SpecFlow.Table table102 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table105 = new TechTalk.SpecFlow.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table102.AddRow(new string[] { + table105.AddRow(new string[] { "Safaricom", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table102.AddRow(new string[] { + table105.AddRow(new string[] { "Voucher", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table102.AddRow(new string[] { + table105.AddRow(new string[] { "Safaricom", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table102.AddRow(new string[] { + table105.AddRow(new string[] { "Voucher", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); -#line 115 - testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table102, "Given "); +#line 124 + testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table105, "Given "); #line hidden - TechTalk.SpecFlow.Table table103 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table106 = new TechTalk.SpecFlow.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table103.AddRow(new string[] { + table106.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); - table103.AddRow(new string[] { + table106.AddRow(new string[] { "123456781", "Test Merchant 2", "Test Estate 1"}); -#line 122 - testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table103, "Given "); +#line 131 + testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table106, "Given "); #line hidden - TechTalk.SpecFlow.Table table104 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table107 = new TechTalk.SpecFlow.Table(new string[] { + "EstateName", + "MerchantName", + "ContractDescription"}); + table107.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "Safaricom Contract"}); + table107.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 1", + "Hospital 1 Contract"}); + table107.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 2", + "Safaricom Contract"}); + table107.AddRow(new string[] { + "Test Estate 1", + "Test Merchant 2", + "Hospital 1 Contract"}); +#line 136 + testRunner.When("I add the following contracts to the following merchants", ((string)(null)), table107, "When "); +#line hidden + TechTalk.SpecFlow.Table table108 = new TechTalk.SpecFlow.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table104.AddRow(new string[] { + table108.AddRow(new string[] { "Deposit1", "210.00", "Today", "Test Merchant 1", "Test Estate 1"}); - table104.AddRow(new string[] { + table108.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 2", "Test Estate 1"}); -#line 127 - testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table104, "Given "); +#line 143 + testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table108, "Given "); #line hidden - TechTalk.SpecFlow.Table table105 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table109 = new TechTalk.SpecFlow.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -780,7 +834,7 @@ public void ProcessSettlement() "ProductName", "RecipientEmail", "RecipientMobile"}); - table105.AddRow(new string[] { + table109.AddRow(new string[] { "2022-01-06", "1", "Sale", @@ -796,7 +850,7 @@ public void ProcessSettlement() "Variable Topup", "", ""}); - table105.AddRow(new string[] { + table109.AddRow(new string[] { "2022-01-06", "2", "Sale", @@ -812,7 +866,7 @@ public void ProcessSettlement() "Variable Topup", "", ""}); - table105.AddRow(new string[] { + table109.AddRow(new string[] { "2022-01-06", "4", "Sale", @@ -828,7 +882,7 @@ public void ProcessSettlement() "Variable Topup", "", ""}); - table105.AddRow(new string[] { + table109.AddRow(new string[] { "2022-01-06", "5", "Sale", @@ -844,7 +898,7 @@ public void ProcessSettlement() "10 KES", "test@recipient.co.uk", ""}); - table105.AddRow(new string[] { + table109.AddRow(new string[] { "2022-01-06", "6", "Sale", @@ -860,62 +914,62 @@ public void ProcessSettlement() "10 KES", "", "123456789"}); -#line 132 - testRunner.When("I perform the following transactions", ((string)(null)), table105, "When "); +#line 148 + testRunner.When("I perform the following transactions", ((string)(null)), table109, "When "); #line hidden - TechTalk.SpecFlow.Table table106 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table110 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table106.AddRow(new string[] { + table110.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1", "0000", "SUCCESS"}); - table106.AddRow(new string[] { + table110.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "2", "0000", "SUCCESS"}); - table106.AddRow(new string[] { + table110.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "4", "0000", "SUCCESS"}); - table106.AddRow(new string[] { + table110.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "5", "0000", "SUCCESS"}); - table106.AddRow(new string[] { + table110.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "6", "0000", "SUCCESS"}); -#line 140 - testRunner.Then("transaction response should contain the following information", ((string)(null)), table106, "Then "); +#line 156 + testRunner.Then("transaction response should contain the following information", ((string)(null)), table110, "Then "); #line hidden - TechTalk.SpecFlow.Table table107 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table111 = new TechTalk.SpecFlow.Table(new string[] { "SettlementDate", "EstateName", "MerchantName", "NumberOfFees"}); - table107.AddRow(new string[] { + table111.AddRow(new string[] { "2022-01-13", "Test Estate 1", "Test Merchant 2", "1"}); -#line 148 - testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table107, "When "); +#line 164 + testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table111, "When "); #line hidden -#line 152 +#line 168 testRunner.When("I process the settlement for \'2022-01-13\' on Estate \'Test Estate 1\' for Merchant " + "\'Test Merchant 2\' then 1 fees are marked as settled and the settlement is comple" + "ted", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 0833fffb..6dbe8e19 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -4,6 +4,7 @@ namespace TransactionProcessor.IntegrationTests.Shared { using System.Linq; + using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Common; @@ -12,6 +13,7 @@ namespace TransactionProcessor.IntegrationTests.Shared using EstateManagement.DataTransferObjects.Responses; using EstateManagement.IntegrationTesting.Helpers; using IntegrationTesting.Helpers; + using Newtonsoft.Json.Linq; using SecurityService.DataTransferObjects.Requests; using SecurityService.IntegrationTesting.Helpers; using Shouldly; @@ -129,8 +131,6 @@ await this.TestingContext.DockerHelper { this.TestingContext.AddEstateDetails(verifiedEstate.EstateId, verifiedEstate.EstateName, verifiedEstate.EstateReference); this.TestingContext.Logger.LogInformation($"Estate {verifiedEstate.EstateName} created with Id {verifiedEstate.EstateId}"); - - } } @@ -179,8 +179,9 @@ public async Task WhenICreateTheFollowingMerchants(Table table) List verifiedMerchants = await this.EstateManagementSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); - foreach (MerchantResponse verifiedMerchant in verifiedMerchants) - { + foreach (MerchantResponse verifiedMerchant in verifiedMerchants){ + await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, verifiedMerchant.EstateId, verifiedMerchant.MerchantId); + EstateDetails estateDetails = this.TestingContext.GetEstateDetails(verifiedMerchant.EstateId); estateDetails.AddMerchant(verifiedMerchant); this.TestingContext.Logger.LogInformation($"Merchant {verifiedMerchant.MerchantName} created with Id {verifiedMerchant.MerchantId} for Estate {estateDetails.EstateName}"); @@ -262,6 +263,21 @@ public async Task GivenIHaveAssignedTheFollowingDevicesToTheMerchants(Table tabl } } + [When(@"I add the following contracts to the following merchants")] + public async Task WhenIAddTheFollowingContractsToTheFollowingMerchants(Table table) + { + List<(EstateDetails, Guid, Guid)> requests = table.Rows.ToAddContractToMerchantRequests(this.TestingContext.Estates); + await this.EstateManagementSteps.WhenIAddTheFollowingContractsToTheFollowingMerchants(this.TestingContext.AccessToken, requests); + } + + private async Task GetMerchantBalance(Guid merchantId) + { + JsonElement jsonElement = (JsonElement)await this.TestingContext.DockerHelper.ProjectionManagementClient.GetStateAsync("MerchantBalanceProjection", $"MerchantBalance-{merchantId:N}"); + JObject jsonObject = JObject.Parse(jsonElement.GetRawText()); + decimal balanceValue = jsonObject.SelectToken("merchant.balance").Value(); + return balanceValue; + } + [Given(@"I make the following manual merchant deposits")] public async Task GivenIMakeTheFollowingManualMerchantDeposits(Table table) { @@ -269,14 +285,14 @@ public async Task GivenIMakeTheFollowingManualMerchantDeposits(Table table) foreach ((EstateDetails, Guid, MakeMerchantDepositRequest) request in requests) { - MerchantBalanceResponse previousMerchantBalance = await this.TestingContext.DockerHelper.TransactionProcessorClient.GetMerchantBalance(this.TestingContext.AccessToken, - request.Item1.EstateId, request.Item2, CancellationToken.None); + Decimal previousMerchantBalance = await this.GetMerchantBalance(request.Item2); await this.EstateManagementSteps.GivenIMakeTheFollowingManualMerchantDeposits(this.TestingContext.AccessToken, request); await Retry.For(async () => { - MerchantBalanceResponse currentMerchantBalance = await this.TestingContext.DockerHelper.TransactionProcessorClient.GetMerchantBalance(this.TestingContext.AccessToken, request.Item1.EstateId, request.Item2, CancellationToken.None); - currentMerchantBalance.AvailableBalance.ShouldBe(previousMerchantBalance.AvailableBalance + request.Item3.Amount); + Decimal currentMerchantBalance = await this.GetMerchantBalance(request.Item2); + + currentMerchantBalance.ShouldBe(previousMerchantBalance + request.Item3.Amount); this.TestingContext.Logger.LogInformation($"Deposit Reference {request.Item3.Reference} made for Merchant Id {request.Item2}"); }); diff --git a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj index 712b7804..5b818617 100644 --- a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj +++ b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/TransactionProcessor.ProjectionEngine/ProjectionHandler/ProjectionHandler.cs b/TransactionProcessor.ProjectionEngine/ProjectionHandler/ProjectionHandler.cs index 68fbdffc..4fb95029 100644 --- a/TransactionProcessor.ProjectionEngine/ProjectionHandler/ProjectionHandler.cs +++ b/TransactionProcessor.ProjectionEngine/ProjectionHandler/ProjectionHandler.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Text; using Dispatchers; +using Newtonsoft.Json; using Projections; using Repository; using Shared.DomainDrivenDesign.EventSourcing; @@ -27,12 +28,12 @@ public ProjectionHandler(IProjectionStateRepository projectionStateRepos public async Task Handle(IDomainEvent @event, CancellationToken cancellationToken) { if (@event == null) return; - + if (this.Projection.ShouldIHandleEvent(@event) == false) { return; } - + Stopwatch stopwatch = Stopwatch.StartNew(); StringBuilder builder = new(); @@ -49,7 +50,7 @@ public async Task Handle(IDomainEvent @event, CancellationToken cancellationToke builder.Append($"{stopwatch.ElapsedMilliseconds}ms Handling {@event.EventType} Id [{@event.EventId}] for state {state.GetType().Name}|"); TState newState = await this.Projection.Handle(state, @event, cancellationToken); - + builder.Append($"{stopwatch.ElapsedMilliseconds}ms After Handle|"); if (newState != state) @@ -58,7 +59,7 @@ public async Task Handle(IDomainEvent @event, CancellationToken cancellationToke { ChangesApplied = true }; - + // save state newState = await this.ProjectionStateRepository.Save(newState, @event, cancellationToken); @@ -67,7 +68,7 @@ public async Task Handle(IDomainEvent @event, CancellationToken cancellationToke if (this.StateDispatcher != null) { - //Send to anyone else interested + // Send to anyone else interested await this.StateDispatcher.Dispatch(newState, @event, cancellationToken); builder.Append($"{stopwatch.ElapsedMilliseconds}ms After Dispatch|"); @@ -83,6 +84,7 @@ public async Task Handle(IDomainEvent @event, CancellationToken cancellationToke builder.Insert(0, $"Total time: {stopwatch.ElapsedMilliseconds}ms|"); Logger.LogWarning(builder.ToString()); + Logger.LogInformation($"Event Type {@event.EventType} Id [{@event.EventId}] for state {state.GetType().Name} took {stopwatch.ElapsedMilliseconds}ms to process"); } } \ No newline at end of file diff --git a/TransactionProcessor.ProjectionEngine/Repository/MerchantBalanceStateRepository.cs b/TransactionProcessor.ProjectionEngine/Repository/MerchantBalanceStateRepository.cs index b83b1a4e..5df56caa 100644 --- a/TransactionProcessor.ProjectionEngine/Repository/MerchantBalanceStateRepository.cs +++ b/TransactionProcessor.ProjectionEngine/Repository/MerchantBalanceStateRepository.cs @@ -5,6 +5,8 @@ using Shared.DomainDrivenDesign.EventSourcing; using State; using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; +using Shared.Logger; using TransactionProcessor.ProjectionEngine.Database.Database; using TransactionProcessor.ProjectionEngine.Database.Database.Entities; using MerchantBalanceProjectionState = Database.Database.Entities.MerchantBalanceProjectionState; @@ -58,6 +60,7 @@ public async Task Load(Guid estateId, public async Task Save(MerchantBalanceState state, IDomainEvent domainEvent, CancellationToken cancellationToken) { + await using TransactionProcessorGenericContext context = await this.ContextFactory.GetContext(state.EstateId, MerchantBalanceStateRepository.ConnectionStringIdentifier, cancellationToken); // Note: we don't want to select the state again here.... @@ -126,7 +129,7 @@ private async Task LoadHelper(Guid estateId, if (entity == null) { return new MerchantBalanceState(); } - + // We have located a state record so we need to translate to the Model type return new MerchantBalanceState { Version = entity.Timestamp, diff --git a/TransactionProcessor/Startup.cs b/TransactionProcessor/Startup.cs index f9d47581..f5913f54 100644 --- a/TransactionProcessor/Startup.cs +++ b/TransactionProcessor/Startup.cs @@ -6,6 +6,7 @@ namespace TransactionProcessor using System.IO; using System.Linq; using System.Net.Http; + using System.Reflection; using System.Runtime.InteropServices.ComTypes; using System.Threading; using Bootstrapper; @@ -25,6 +26,7 @@ namespace TransactionProcessor using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; + using NLog; using NLog.Extensions.Logging; using NuGet.Protocol; using ProjectionEngine.EventHandling; @@ -35,12 +37,13 @@ namespace TransactionProcessor using Shared.EventStore.EventHandling; using Shared.Extensions; using Shared.General; - using Shared.Logger; using Transaction.DomainEvents; using TransactionProcessor.BusinessLogic.OperatorInterfaces; using Voucher.DomainEvents; using EventHandler = ProjectionEngine.EventHandling.EventHandler; using ILogger = Microsoft.Extensions.Logging.ILogger; + using Logger = Shared.Logger.Logger; + using SetupBuilderExtensions = NLog.SetupBuilderExtensions; /// /// @@ -123,6 +126,10 @@ public void Configure(IApplicationBuilder app, app.UseDeveloperExceptionPage(); } + string directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + LogManager.AddHiddenAssembly(Assembly.LoadFrom($"{directoryPath}\\Shared.dll")); + loggerFactory.ConfigureNLog(Path.Combine(env.ContentRootPath, nlogConfigFilename)); loggerFactory.AddNLog();