From 29e71b93f4b401ebc9efd1d65f12ca80535aacf6 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Sun, 17 Mar 2024 11:57:30 +0000 Subject: [PATCH 1/5] Reqnroll upgrade completed --- .../TransactionProcessor.BusinessLogic.csproj | 12 +- .../TransactionProcessor.Client.csproj | 2 +- ...sactionProcessor.Float.DomainEvents.csproj | 2 +- ...TransactionProcessor.FloatAggregate.csproj | 2 +- .../SpecflowExtensions.cs | 688 +++++------------- .../SubscriptionsHelper.cs | 20 + ...rocessor.IntegrationTesting.Helpers.csproj | 4 +- .../TransactionProcessorSteps.cs | 20 +- .../Common/DockerHelper.cs | 31 +- .../Common/GenericSteps.cs | 55 +- .../Common/Setup.cs | 20 +- .../Common/SpecflowTableHelper.cs | 133 ---- .../Common/TestingContext.cs | 8 +- .../Features/LogonTransaction.feature.cs | 156 ++-- .../Features/ReconciliationFeature.feature.cs | 140 ++-- .../Features/RedeemVoucher.feature.cs | 140 ++-- .../SaleTransactionFeature.feature.cs | 236 +++--- .../Features/Settlement.feature.cs | 198 ++--- .../Shared/SharedSteps.cs | 94 +-- ...ansactionProcessor.IntegrationTests.csproj | 24 +- .../nlog.config | 2 +- ...Processor.ProjectionEngine.Database.csproj | 4 +- ...ionProcessor.ProjectionEngine.Tests.csproj | 1 - ...ansactionProcessor.ProjectionEngine.csproj | 12 +- ...ocessor.Reconciliation.DomainEvents.csproj | 2 +- ...onProcessor.ReconciliationAggregate.csproj | 2 +- ...onProcessor.Settlement.DomainEvents.csproj | 2 +- ...ctionProcessor.SettlementAggregates.csproj | 2 +- ...nProcessor.Transaction.DomainEvents.csproj | 2 +- ...ctionProcessor.TransactionAggregate.csproj | 2 +- ...ctionProcessor.Voucher.DomainEvents.csproj | 2 +- ...ansactionProcessor.VoucherAggregate.csproj | 2 +- .../TransactionProcessor.csproj | 4 +- 33 files changed, 808 insertions(+), 1216 deletions(-) create mode 100644 TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs delete mode 100644 TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs diff --git a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj index baf713bb..86253674 100644 --- a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj +++ b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj @@ -5,13 +5,13 @@ - - + + - - - - + + + + diff --git a/TransactionProcessor.Client/TransactionProcessor.Client.csproj b/TransactionProcessor.Client/TransactionProcessor.Client.csproj index 065ac651..a60559b9 100644 --- a/TransactionProcessor.Client/TransactionProcessor.Client.csproj +++ b/TransactionProcessor.Client/TransactionProcessor.Client.csproj @@ -6,7 +6,7 @@ - + diff --git a/TransactionProcessor.Float.DomainEvents/TransactionProcessor.Float.DomainEvents.csproj b/TransactionProcessor.Float.DomainEvents/TransactionProcessor.Float.DomainEvents.csproj index 0f5342fc..dff8c337 100644 --- a/TransactionProcessor.Float.DomainEvents/TransactionProcessor.Float.DomainEvents.csproj +++ b/TransactionProcessor.Float.DomainEvents/TransactionProcessor.Float.DomainEvents.csproj @@ -7,7 +7,7 @@ - + diff --git a/TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj b/TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj index a4421fcd..0e2908bc 100644 --- a/TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj +++ b/TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj @@ -7,7 +7,7 @@ - + diff --git a/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs b/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs index b0922112..0a44e325 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs @@ -7,519 +7,6 @@ using Reqnroll; using Shared.IntegrationTesting; using Shouldly; -using TechTalk.SpecFlow; - -public static class SpecflowExtensions -{ - private static EstateDetails GetEstateDetails(List estateDetailsList, String estateName) - { - EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); - - if (estateDetails == null && estateName == "InvalidEstate") - { - estateDetails = EstateDetails.Create(Guid.Parse("79902550-64DF-4491-B0C1-4E78943928A3"), estateName, "EstateRef1"); - estateDetails.AddMerchant(new MerchantResponse - { - MerchantId = Guid.Parse("36AA0109-E2E3-4049-9575-F507A887BB1F"), - MerchantName = "Test Merchant 1" - }); - estateDetailsList.Add(estateDetails); - } - else - { - estateDetails.ShouldNotBeNull(); - } - - return estateDetails; - } - - public static List<(EstateDetails, Guid, String, SerialisedMessage)> ToSerialisedMessages(this TableRows tableRows, List estateDetailsList) - { - - List<(EstateDetails, Guid, String, SerialisedMessage)> messages = new List<(EstateDetails, Guid, String, SerialisedMessage)>(); - foreach (TableRow tableRow in tableRows) - { - String transactionType = SpecflowTableHelper.GetStringRowValue(tableRow, "TransactionType"); - String dateString = SpecflowTableHelper.GetStringRowValue(tableRow, "DateTime"); - DateTime transactionDateTime = SpecflowTableHelper.GetDateForDateString(dateString, DateTime.UtcNow); - String transactionNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "TransactionNumber"); - String deviceIdentifier = SpecflowTableHelper.GetStringRowValue(tableRow, "DeviceIdentifier"); - - String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); - - EstateDetails estateDetails = SpecflowExtensions.GetEstateDetails(estateDetailsList, estateName); - - String merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); - Guid merchantId = estateDetails.GetMerchantId(merchantName); - - String serialisedData = null; - if (transactionType == "Logon") - { - LogonTransactionRequest logonTransactionRequest = new LogonTransactionRequest - { - MerchantId = merchantId, - EstateId = estateDetails.EstateId, - TransactionDateTime = transactionDateTime, - TransactionNumber = transactionNumber, - DeviceIdentifier = deviceIdentifier, - TransactionType = transactionType - }; - serialisedData = JsonConvert.SerializeObject(logonTransactionRequest, - new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); - - } - - if (transactionType == "Sale") - { - // Get specific sale fields - String operatorName = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName"); - Decimal transactionAmount = SpecflowTableHelper.GetDecimalValue(tableRow, "TransactionAmount"); - String customerAccountNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "CustomerAccountNumber"); - String customerEmailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "CustomerEmailAddress"); - String contractDescription = SpecflowTableHelper.GetStringRowValue(tableRow, "ContractDescription"); - String productName = SpecflowTableHelper.GetStringRowValue(tableRow, "ProductName"); - Int32 transactionSource = SpecflowTableHelper.GetIntValue(tableRow, "TransactionSource"); - String recipientEmail = SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientEmail"); - String recipientMobile = SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientMobile"); - String messageType = SpecflowTableHelper.GetStringRowValue(tableRow, "MessageType"); - String accountNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "AccountNumber"); - String customerName = SpecflowTableHelper.GetStringRowValue(tableRow, "CustomerName"); - String meterNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "MeterNumber"); - - Guid contractId = Guid.Empty; - Guid productId = Guid.Empty; - EstateManagement.IntegrationTesting.Helpers.Contract contract = null; - EstateManagement.IntegrationTesting.Helpers.Product product = null; - try - { - contract = estateDetails.GetContract(contractDescription); - } - catch (Exception ex) - { - - } - - if (contract != null) - { - contractId = contract.ContractId; - product = contract.GetProduct(productName); - if (product != null) - { - productId = product.ProductId; - } - else - { - productId = productName switch - { - "EmptyProduct" => Guid.Empty, - "InvalidProduct" => Guid.Parse("934d8164-f36a-448e-b27b-4d671d41d180"), - _ => Guid.NewGuid(), - }; - } - } - else - { - // This is a nasty hack atm... - contractId = contractDescription switch - { - "EmptyContract" => Guid.Empty, - "InvalidContract" => Guid.Parse("934d8164-f36a-448e-b27b-4d671d41d180"), - _ => Guid.NewGuid(), - }; - - - } - - SaleTransactionRequest saleTransactionRequest = new SaleTransactionRequest - { - MerchantId = merchantId, - EstateId = estateDetails.EstateId, - TransactionDateTime = transactionDateTime, - TransactionNumber = transactionNumber, - DeviceIdentifier = deviceIdentifier, - TransactionType = transactionType, - OperatorIdentifier = operatorName, - CustomerEmailAddress = customerEmailAddress, - ProductId = productId, - ContractId = contractId, - TransactionSource = transactionSource - }; - - saleTransactionRequest.AdditionalTransactionMetadata = operatorName switch - { - "Voucher" => SpecflowExtensions.BuildVoucherTransactionMetaData(recipientEmail, recipientMobile, transactionAmount), - "PataPawa PostPay" => SpecflowExtensions.BuildPataPawaPostPayMetaData(messageType, accountNumber, recipientMobile, customerName, transactionAmount), - "PataPawa PrePay" => SpecflowExtensions.BuildPataPawaPrePayMetaData(messageType, meterNumber, customerName, transactionAmount), - _ => SpecflowExtensions.BuildMobileTopupMetaData(transactionAmount, customerAccountNumber) - }; - serialisedData = JsonConvert.SerializeObject(saleTransactionRequest, - new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); - } - - if (transactionType == "Reconciliation") - { - Int32 transactionCount = SpecflowTableHelper.GetIntValue(tableRow, "TransactionCount"); - Decimal transactionValue = SpecflowTableHelper.GetDecimalValue(tableRow, "TransactionValue"); - - ReconciliationRequest reconciliationRequest = new ReconciliationRequest - { - MerchantId = merchantId, - EstateId = estateDetails.EstateId, - TransactionDateTime = transactionDateTime, - DeviceIdentifier = deviceIdentifier, - TransactionValue = transactionValue, - TransactionCount = transactionCount, - }; - - serialisedData = JsonConvert.SerializeObject(reconciliationRequest, - new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); - } - - SerialisedMessage serialisedMessage = new SerialisedMessage(); - serialisedMessage.Metadata.Add(MetadataContants.KeyNameEstateId, estateDetails.EstateId.ToString()); - serialisedMessage.Metadata.Add(MetadataContants.KeyNameMerchantId, merchantId.ToString()); - serialisedMessage.SerialisedData = serialisedData; - messages.Add((estateDetails, merchantId, transactionNumber, serialisedMessage)); - } - - return messages; - } - - public static List<(SerialisedMessage, String, String, String)> GetTransactionDetails(this TableRows tableRows, List estateDetailsList) - { - List<(SerialisedMessage, String, String, String)> expectedValuesForTransaction = new List<(SerialisedMessage, String, String, String)>(); - - foreach (TableRow tableRow in tableRows) - { - String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); - EstateDetails estateDetails = SpecflowExtensions.GetEstateDetails(estateDetailsList, estateName); - - String merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); - Guid merchantId = estateDetails.GetMerchantId(merchantName); - - String transactionNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "TransactionNumber"); - String expectedResponseCode = SpecflowTableHelper.GetStringRowValue(tableRow, "ResponseCode"); - String expectedResponseMessage = SpecflowTableHelper.GetStringRowValue(tableRow, "ResponseMessage"); - - var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber); - var serialisedMessage = JsonConvert.DeserializeObject(message); - expectedValuesForTransaction.Add((serialisedMessage, transactionNumber, expectedResponseCode, expectedResponseMessage)); - } - - return expectedValuesForTransaction; - } - - public static List ToBalanceEntries(this TableRows tableRows, String estateName, String merchantName, List estateDetailsList) - { - List balanceEntries = new List(); - foreach (TableRow tableRow in tableRows) - { - EstateDetails estateDetails = SpecflowExtensions.GetEstateDetails(estateDetailsList, estateName); - Guid merchantId = estateDetails.GetMerchantId(merchantName); - - DateTime entryDateTime = SpecflowTableHelper.GetDateForDateString(tableRow["DateTime"], DateTime.UtcNow); - String reference = SpecflowTableHelper.GetStringRowValue(tableRow, "Reference"); - String debitOrCredit = SpecflowTableHelper.GetStringRowValue(tableRow, "EntryType"); - Decimal changeAmount = SpecflowTableHelper.GetDecimalValue(tableRow, "ChangeAmount"); - - BalanceEntry balanceEntry = new BalanceEntry - { - ChangeAmount = changeAmount, - MerchantId = merchantId, - EntryType = debitOrCredit, - DateTime = entryDateTime, - EstateId = estateDetails.EstateId, - Reference = reference - }; - balanceEntries.Add(balanceEntry); - } - - return balanceEntries; - } - - public static List ToPataPawaBills(this TableRows tableRows) - { - List bills = new List(); - foreach (TableRow tableRow in tableRows) - { - PataPawaBill bill = new PataPawaBill - { - due_date = SpecflowTableHelper.GetDateForDateString(tableRow["DueDate"], DateTime.Now), - amount = SpecflowTableHelper.GetDecimalValue(tableRow, "Amount"), - account_number = SpecflowTableHelper.GetStringRowValue(tableRow, "AccountNumber"), - account_name = SpecflowTableHelper.GetStringRowValue(tableRow, "AccountName") - }; - bills.Add(bill); - } - return bills; - } - - public static List ToPataPawaUsers(this TableRows tableRows) - { - List users = new List(); - foreach (TableRow tableRow in tableRows) - { - PataPawaUser user = new PataPawaUser - { - user_name = SpecflowTableHelper.GetStringRowValue(tableRow, "Username"), - password = SpecflowTableHelper.GetStringRowValue(tableRow, "Password") - }; - users.Add(user); - } - return users; - } - - public static List ToPataPawaMeters(this TableRows tableRows) - { - List meters = new List(); - foreach (TableRow tableRow in tableRows) - { - PataPawaMeter meter = new PataPawaMeter - { - meter_number = SpecflowTableHelper.GetStringRowValue(tableRow, "MeterNumber"), - customer_name = SpecflowTableHelper.GetStringRowValue(tableRow, "CustomerName") - }; - meters.Add(meter); - } - return meters; - } - - private static Dictionary BuildMobileTopupMetaData(Decimal transactionAmount, String customerAccountNumber) - { - return new Dictionary - { - {"Amount", transactionAmount.ToString()}, - {"CustomerAccountNumber", customerAccountNumber} - }; - } - - private static Dictionary BuildPataPawaPostPayMetaData(String messageType, String accountNumber, String recipientMobile, - String customerName, Decimal transactionAmount) - { - return messageType switch - { - "VerifyAccount" => SpecflowExtensions.BuildPataPawaMetaDataForVerifyAccount(accountNumber), - "ProcessBill" => SpecflowExtensions.BuildPataPawaMetaDataForProcessBill(accountNumber, recipientMobile, customerName, transactionAmount), - _ => throw new Exception($"Unsupported message type [{messageType}]") - }; - } - - private static Dictionary BuildPataPawaPrePayMetaData(String messageType, String meterNumber, - String customerName, Decimal transactionAmount) - { - return messageType switch - { - "meter" => SpecflowExtensions.BuildPataPawaMetaDataForMeter(meterNumber), - "vend" => SpecflowExtensions.BuildPataPawaMetaDataForVend(meterNumber,transactionAmount, customerName), - _ => throw new Exception($"Unsupported message type [{messageType}]") - }; - } - - private static Dictionary BuildPataPawaMetaDataForVerifyAccount(String accountNumber) - { - return new Dictionary - { - {"PataPawaPostPaidMessageType", "VerifyAccount"}, - {"CustomerAccountNumber", accountNumber} - }; - } - - private static Dictionary BuildPataPawaMetaDataForMeter(String meterNumber) - { - return new Dictionary - { - {"PataPawaPrePayMessageType", "meter"}, - {"MeterNumber", meterNumber} - }; - } - - private static Dictionary BuildPataPawaMetaDataForVend(String meterNumber, Decimal transactionAmount, String customerName) - { - return new Dictionary - { - {"PataPawaPrePayMessageType", "vend"}, - {"MeterNumber", meterNumber}, - {"Amount", transactionAmount.ToString()}, - {"CustomerName", customerName} - }; - } - - private static Dictionary BuildVoucherTransactionMetaData(String recipientEmail, - String recipientMobile, - Decimal transactionAmount) - { - Dictionary additionalTransactionMetadata = new Dictionary{ - { "Amount", transactionAmount.ToString() }, - }; - - if (String.IsNullOrEmpty(recipientEmail) == false) - { - additionalTransactionMetadata.Add("RecipientEmail", recipientEmail); - } - - if (String.IsNullOrEmpty(recipientMobile) == false) - { - additionalTransactionMetadata.Add("RecipientMobile", recipientMobile); - } - - return additionalTransactionMetadata; - } - private static Dictionary BuildPataPawaMetaDataForProcessBill(String accountNumber, - String recipientMobile, - String customerName, - Decimal transactionAmount) - { - return new Dictionary - { - {"PataPawaPostPaidMessageType", "ProcessBill"}, - {"Amount", transactionAmount.ToString()}, - {"CustomerAccountNumber", accountNumber}, - {"MobileNumber", recipientMobile}, - {"CustomerName", customerName}, - }; - } - - public static List GetTransactionResendDetails(this TableRows tableRows, List estateDetailsList) - { - List serialisedMessages = new List(); - - foreach (TableRow tableRow in tableRows) - { - String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); - EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); - estateDetails.ShouldNotBeNull(); - - String merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); - Guid merchantId = estateDetails.GetMerchantId(merchantName); - - String transactionNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "TransactionNumber"); - var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber); - var serialisedMessage = JsonConvert.DeserializeObject(message); - serialisedMessages.Add(serialisedMessage); - } - return serialisedMessages; - } - - public static (EstateDetails, SaleTransactionResponse) GetVoucherByTransactionNumber(String estateName, String merchantName, Int32 transactionNumber, List estateDetailsList) - { - EstateDetails estateDetails = SpecflowExtensions.GetEstateDetails(estateDetailsList, estateName); - - Guid merchantId = estateDetails.GetMerchantId(merchantName); - var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber.ToString()); - var serialisedMessage = JsonConvert.DeserializeObject(message); - SaleTransactionResponse transactionResponse = JsonConvert.DeserializeObject(serialisedMessage.SerialisedData, - new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); - return (estateDetails, transactionResponse); - } - - public static ProcessSettlementRequest ToProcessSettlementRequest(String dateString, String estateName, String merchantName, List estateDetailsList) - { - DateTime settlementDate = SpecflowTableHelper.GetDateForDateString(dateString, DateTime.UtcNow.Date); - - EstateDetails estateDetails = SpecflowExtensions.GetEstateDetails(estateDetailsList, estateName); - Guid merchantId = estateDetails.GetMerchantId(merchantName); - - return new ProcessSettlementRequest - { - MerchantId = merchantId, - EstateDetails = estateDetails, - SettlementDate = settlementDate, - }; - } - - public static List<(EstateDetails, Guid, DateTime, Int32)> ToCompletedSettlementRequests(this TableRows tableRows, List estateDetailsList) - { - List<(EstateDetails, Guid, DateTime, Int32)> results = new List<(EstateDetails, Guid, DateTime, Int32)>(); - foreach (TableRow tableRow in tableRows) - { - // Get the merchant name - String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); - EstateDetails estateDetails = SpecflowExtensions.GetEstateDetails(estateDetailsList, estateName); - - Guid merchantId = estateDetails.GetMerchantId(SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName")); - String settlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "SettlementDate"); - Int32 numberOfFees = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfFees"); - DateTime settlementDate = SpecflowTableHelper.GetDateForDateString(settlementDateString, DateTime.UtcNow.Date); - - results.Add((estateDetails, merchantId, settlementDate, numberOfFees)); - } - - return results; - } - - public static List<(EstateDetails, Guid, DateTime, Int32)> ToPendingSettlementRequests(this TableRows tableRows, List estateDetailsList) - { - List<(EstateDetails, Guid, DateTime, Int32)> results = new List<(EstateDetails, Guid, DateTime, Int32)>(); - foreach (TableRow tableRow in tableRows) - { - // Get the merchant name - String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); - EstateDetails estateDetails = SpecflowExtensions.GetEstateDetails(estateDetailsList, estateName); - - Guid merchantId = estateDetails.GetMerchantId(SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName")); - String settlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "SettlementDate"); - Int32 numberOfFees = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfFees"); - DateTime settlementDate = SpecflowTableHelper.GetDateForDateString(settlementDateString, DateTime.UtcNow.Date); - - results.Add((estateDetails, merchantId, settlementDate, numberOfFees)); - } - - return results; - } - - public class BalanceEntry - { - public Guid EstateId { get; set; } - public Guid MerchantId { get; set; } - public DateTime DateTime { get; set; } - public String Reference { get; set; } - public String EntryType { get; set; } - public Decimal In { get; set; } - public Decimal Out { get; set; } - public Decimal ChangeAmount { get; set; } - public Decimal Balance { get; set; } - } - - public class PataPawaBill - { - public DateTime due_date { get; set; } - public Decimal amount { get; set; } - public String account_number { get; set; } - public String account_name { get; set; } - } - - public class PataPawaUser - { - public String user_name { get; set; } - public String password { get; set; } - } - - public class PataPawaMeter - { - public String meter_number { get; set; } - public String customer_name { get; set; } - } - - public class ProcessSettlementRequest - { - public DateTime SettlementDate { get; set; } - public EstateDetails EstateDetails { get; set; } - public Guid MerchantId { get; set; } - } -} - public static class ReqnrollTableHelper { @@ -901,18 +388,189 @@ private static Dictionary BuildPataPawaMetaDataForProcessBill(St }; } - public static SpecflowExtensions.ProcessSettlementRequest ToProcessSettlementRequest(String dateString, String estateName, String merchantName, List estateDetailsList) + public static ProcessSettlementRequest ToProcessSettlementRequest(String dateString, String estateName, String merchantName, List estateDetailsList) { DateTime settlementDate = ReqnrollTableHelper.GetDateForDateString(dateString, DateTime.UtcNow.Date); EstateDetails estateDetails = ReqnrollExtensions.GetEstateDetails(estateDetailsList, estateName); Guid merchantId = estateDetails.GetMerchantId(merchantName); - return new SpecflowExtensions.ProcessSettlementRequest + return new ProcessSettlementRequest { MerchantId = merchantId, EstateDetails = estateDetails, SettlementDate = settlementDate, }; } + + public static List GetTransactionResendDetails(this DataTableRows tableRows, List estateDetailsList) + { + List serialisedMessages = new List(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String merchantName = ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName"); + Guid merchantId = estateDetails.GetMerchantId(merchantName); + + String transactionNumber = ReqnrollTableHelper.GetStringRowValue(tableRow, "TransactionNumber"); + var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber); + var serialisedMessage = JsonConvert.DeserializeObject(message); + serialisedMessages.Add(serialisedMessage); + } + return serialisedMessages; + } + + public static List ToBalanceEntries(this DataTableRows tableRows, String estateName, String merchantName, List estateDetailsList) + { + List balanceEntries = new List(); + foreach (DataTableRow tableRow in tableRows) + { + EstateDetails estateDetails = ReqnrollExtensions.GetEstateDetails(estateDetailsList, estateName); + Guid merchantId = estateDetails.GetMerchantId(merchantName); + + DateTime entryDateTime = ReqnrollTableHelper.GetDateForDateString(tableRow["DateTime"], DateTime.UtcNow); + String reference = ReqnrollTableHelper.GetStringRowValue(tableRow, "Reference"); + String debitOrCredit = ReqnrollTableHelper.GetStringRowValue(tableRow, "EntryType"); + Decimal changeAmount = ReqnrollTableHelper.GetDecimalValue(tableRow, "ChangeAmount"); + + BalanceEntry balanceEntry = new BalanceEntry + { + ChangeAmount = changeAmount, + MerchantId = merchantId, + EntryType = debitOrCredit, + DateTime = entryDateTime, + EstateId = estateDetails.EstateId, + Reference = reference + }; + balanceEntries.Add(balanceEntry); + } + + return balanceEntries; + } + + public class BalanceEntry + { + public Guid EstateId { get; set; } + public Guid MerchantId { get; set; } + public DateTime DateTime { get; set; } + public String Reference { get; set; } + public String EntryType { get; set; } + public Decimal In { get; set; } + public Decimal Out { get; set; } + public Decimal ChangeAmount { get; set; } + public Decimal Balance { get; set; } + } + + public class PataPawaBill + { + public DateTime due_date { get; set; } + public Decimal amount { get; set; } + public String account_number { get; set; } + public String account_name { get; set; } + } + + public class PataPawaUser + { + public String user_name { get; set; } + public String password { get; set; } + } + + public class PataPawaMeter + { + public String meter_number { get; set; } + public String customer_name { get; set; } + } + + public class ProcessSettlementRequest + { + public DateTime SettlementDate { get; set; } + public EstateDetails EstateDetails { get; set; } + public Guid MerchantId { get; set; } + } + + public static List<(EstateDetails, Guid, DateTime, Int32)> ToCompletedSettlementRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, Guid, DateTime, Int32)> results = new List<(EstateDetails, Guid, DateTime, Int32)>(); + foreach (DataTableRow tableRow in tableRows) + { + // Get the merchant name + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = ReqnrollExtensions.GetEstateDetails(estateDetailsList, estateName); + + Guid merchantId = estateDetails.GetMerchantId(ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName")); + String settlementDateString = ReqnrollTableHelper.GetStringRowValue(tableRow, "SettlementDate"); + Int32 numberOfFees = ReqnrollTableHelper.GetIntValue(tableRow, "NumberOfFees"); + DateTime settlementDate = ReqnrollTableHelper.GetDateForDateString(settlementDateString, DateTime.UtcNow.Date); + + results.Add((estateDetails, merchantId, settlementDate, numberOfFees)); + } + + return results; + } + + public static List ToPataPawaBills(this DataTableRows tableRows) + { + List bills = new List(); + foreach (DataTableRow tableRow in tableRows) + { + PataPawaBill bill = new PataPawaBill + { + due_date = ReqnrollTableHelper.GetDateForDateString(tableRow["DueDate"], DateTime.Now), + amount = ReqnrollTableHelper.GetDecimalValue(tableRow, "Amount"), + account_number = ReqnrollTableHelper.GetStringRowValue(tableRow, "AccountNumber"), + account_name = ReqnrollTableHelper.GetStringRowValue(tableRow, "AccountName") + }; + bills.Add(bill); + } + return bills; + } + + public static List ToPataPawaUsers(this DataTableRows tableRows) + { + List users = new List(); + foreach (DataTableRow tableRow in tableRows) + { + PataPawaUser user = new PataPawaUser + { + user_name = ReqnrollTableHelper.GetStringRowValue(tableRow, "Username"), + password = ReqnrollTableHelper.GetStringRowValue(tableRow, "Password") + }; + users.Add(user); + } + return users; + } + + public static List ToPataPawaMeters(this DataTableRows tableRows) + { + List meters = new List(); + foreach (DataTableRow tableRow in tableRows) + { + PataPawaMeter meter = new PataPawaMeter + { + meter_number = ReqnrollTableHelper.GetStringRowValue(tableRow, "MeterNumber"), + customer_name = ReqnrollTableHelper.GetStringRowValue(tableRow, "CustomerName") + }; + meters.Add(meter); + } + return meters; + } + + public static (EstateDetails, SaleTransactionResponse) GetVoucherByTransactionNumber(String estateName, String merchantName, Int32 transactionNumber, List estateDetailsList) + { + EstateDetails estateDetails = ReqnrollExtensions.GetEstateDetails(estateDetailsList, estateName); + + Guid merchantId = estateDetails.GetMerchantId(merchantName); + var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber.ToString()); + var serialisedMessage = JsonConvert.DeserializeObject(message); + SaleTransactionResponse transactionResponse = JsonConvert.DeserializeObject(serialisedMessage.SerialisedData, + new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.All + }); + return (estateDetails, transactionResponse); + } } \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs b/TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs new file mode 100644 index 00000000..3daa36fa --- /dev/null +++ b/TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs @@ -0,0 +1,20 @@ +namespace TransactionProcessor.IntegrationTesting.Helpers; + +public static class SubscriptionsHelper +{ + public static List<(String streamName, String groupName, Int32 maxRetries)> GetSubscriptions() + { + List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new(){ + ("$ce-EstateAggregate", "Transaction Processor - Ordered", 2), + ("$ce-MerchantAggregate", "Transaction Processor - Ordered", 2), + ("$ce-MerchantDepositListAggregate", "Transaction Processor - Ordered", 2), + ("$ce-SettlementAggregate", "Transaction Processor", 0), + ("$ce-TransactionAggregate", "Transaction Processor", 0), + ("$ce-TransactionAggregate", "Transaction Processor - Ordered", 2), + ("$ce-VoucherAggregate", "Transaction Processor", 0), + ("$ce-VoucherAggregate", "Transaction Processor - Ordered", 2) + }; + + return subscriptions; + } +} \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj index 2dd8cf4b..3b0b4657 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs index 5cf693cc..220f728c 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs @@ -104,7 +104,7 @@ await this.TransactionProcessorClient.ResendEmailReceipt(accessToken, } } - public async Task ThenTheFollowingEntriesAppearInTheMerchantsBalanceHistoryForEstateAndMerchant(String accessToken, DateTime startDate, DateTime endDate, List balanceEntries) + public async Task ThenTheFollowingEntriesAppearInTheMerchantsBalanceHistoryForEstateAndMerchant(String accessToken, DateTime startDate, DateTime endDate, List balanceEntries) { var merchants = balanceEntries.GroupBy(b => new { b.EstateId, b.MerchantId }).Select(b => new { @@ -117,7 +117,7 @@ public async Task ThenTheFollowingEntriesAppearInTheMerchantsBalanceHistoryForEs foreach (var m in merchants) { List balanceHistory = null; - List merchantEntries = balanceEntries.Where(b => b.EstateId == m.EstateId && b.MerchantId == m.MerchantId).ToList(); + List merchantEntries = balanceEntries.Where(b => b.EstateId == m.EstateId && b.MerchantId == m.MerchantId).ToList(); await Retry.For(async () => { balanceHistory = @@ -131,7 +131,7 @@ await this.TransactionProcessorClient.GetMerchantBalanceHistory(accessToken, balanceHistory.ShouldNotBeNull(); balanceHistory.ShouldNotBeEmpty(); balanceHistory.Count.ShouldBe(m.NumberEntries); - foreach (SpecflowExtensions.BalanceEntry merchantEntry in merchantEntries) + foreach (ReqnrollExtensions.BalanceEntry merchantEntry in merchantEntries) { @@ -161,16 +161,16 @@ public async Task SendRequestToTestHost(List objects, String url){ } } - public async Task GivenTheFollowingBillsAreAvailableAtThePataPawaPostPaidHost(List bills){ - await this.SendRequestToTestHost(bills, "/api/developer/patapawapostpay/createbill"); + public async Task GivenTheFollowingBillsAreAvailableAtThePataPawaPostPaidHost(List bills){ + await this.SendRequestToTestHost(bills, "/api/developer/patapawapostpay/createbill"); } - public async Task GivenTheFollowingMetersAreAvailableAtThePataPawaPrePaidHost(List meters){ - await this.SendRequestToTestHost(meters, "/api/developer/patapawaprepay/createmeter"); + public async Task GivenTheFollowingMetersAreAvailableAtThePataPawaPrePaidHost(List meters){ + await this.SendRequestToTestHost(meters, "/api/developer/patapawaprepay/createmeter"); } - public async Task GivenTheFollowingUsersAreAvailableAtThePataPawaPrePaidHost(List users){ - await this.SendRequestToTestHost(users, "/api/developer/patapawaprepay/createuser"); + public async Task GivenTheFollowingUsersAreAvailableAtThePataPawaPrePaidHost(List users){ + await this.SendRequestToTestHost(users, "/api/developer/patapawaprepay/createuser"); } public async Task GetVoucherByTransactionNumber(String accessToken, EstateDetails estate, SaleTransactionResponse transactionResponse) @@ -203,7 +203,7 @@ await Retry.For(async () => }); } - public async Task WhenIProcessTheSettlementForOnEstateThenFeesAreMarkedAsSettledAndTheSettlementIsCompleted(String accessToken, SpecflowExtensions.ProcessSettlementRequest request, Int32 expectedNumberFeesSettled) + public async Task WhenIProcessTheSettlementForOnEstateThenFeesAreMarkedAsSettledAndTheSettlementIsCompleted(String accessToken, ReqnrollExtensions.ProcessSettlementRequest request, Int32 expectedNumberFeesSettled) { await this.TransactionProcessorClient.ProcessSettlement(accessToken, request.SettlementDate, diff --git a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs index aa6b26a9..cd4df847 100644 --- a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs +++ b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs @@ -72,6 +72,20 @@ public override ContainerBuilder SetupTransactionProcessorContainer(){ return base.SetupTransactionProcessorContainer(); } + public override async Task CreateSubscriptions(){ + List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new(); + subscriptions.AddRange(MessagingService.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); + subscriptions.AddRange(EstateManagement.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); + subscriptions.AddRange(TransactionProcessor.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); + + foreach ((String streamName, String groupName, Int32 maxRetries) subscription in subscriptions) + { + var x = subscription; + x.maxRetries = 2; + await this.CreatePersistentSubscription(x); + } + } + /// /// Starts the containers for scenario run. /// @@ -108,11 +122,11 @@ public override async Task StartContainersForScenarioRun(String scenarioName, Do /// /// Stops the containers for scenario run. /// - public override async Task StopContainersForScenarioRun() + public override async Task StopContainersForScenarioRun(DockerServices dockerServices) { await this.RemoveEstateReadModel().ConfigureAwait(false); - await base.StopContainersForScenarioRun(); + await base.StopContainersForScenarioRun(dockerServices); } private async Task RemoveEstateReadModel() @@ -133,19 +147,6 @@ 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-VoucherAggregate", "Transaction Processor - Ordered", 2), - ($"$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/Common/GenericSteps.cs b/TransactionProcessor.IntegrationTests/Common/GenericSteps.cs index 7497de27..cd9d26ae 100644 --- a/TransactionProcessor.IntegrationTests/Common/GenericSteps.cs +++ b/TransactionProcessor.IntegrationTests/Common/GenericSteps.cs @@ -13,8 +13,7 @@ namespace TransactionProcessor.IntegrationTests.Common using global::Shared.IntegrationTesting; using global::Shared.Logger; using NLog; - using TechTalk.SpecFlow; - using TechTalk.SpecFlow.Plugins; + using Reqnroll; [Binding] [Scope(Tag = "base")] @@ -34,14 +33,52 @@ public GenericSteps(ScenarioContext scenarioContext, [BeforeScenario] public async Task StartSystem() { + //// Initialise a logger + //String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); + //NlogLogger logger = new NlogLogger(); + //logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName); + //LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly); + + //this.TestingContext.DockerHelper = new DockerHelper(); + //this.TestingContext.DockerHelper.Logger = logger; + //this.TestingContext.DockerHelper.SqlServerContainer = Setup.DatabaseServerContainer; + //this.TestingContext.DockerHelper.SqlServerNetwork = Setup.DatabaseServerNetwork; + //this.TestingContext.DockerHelper.DockerCredentials = Setup.DockerCredentials; + //this.TestingContext.DockerHelper.SqlCredentials = Setup.SqlCredentials; + //this.TestingContext.DockerHelper.SqlServerContainerName = "sharedsqlserver"; + + //this.TestingContext.DockerHelper.SetImageDetails(ContainerType.TransactionProcessor, ("transactionprocessor", false)); + + //this.TestingContext.Logger = logger; + //this.TestingContext.Logger.LogInformation("About to Start Containers for Scenario Run"); + + //DockerServices dockerServices = DockerServices.CallbackHandler | DockerServices.EstateManagement | DockerServices.EventStore | + // DockerServices.FileProcessor | DockerServices.MessagingService | DockerServices.SecurityService | + // DockerServices.SqlServer | DockerServices.TestHost | DockerServices.TransactionProcessor | + // DockerServices.TransactionProcessorAcl; + + //await this.TestingContext.DockerHelper.StartContainersForScenarioRun(scenarioName, dockerServices).ConfigureAwait(false); + //this.TestingContext.Logger.LogInformation("Containers for Scenario Run Started"); + // Initialise a logger String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); NlogLogger logger = new NlogLogger(); logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName); LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly); + DockerServices dockerServices = DockerServices.CallbackHandler | DockerServices.EstateManagement | DockerServices.EventStore | + DockerServices.FileProcessor | DockerServices.MessagingService | DockerServices.SecurityService | + DockerServices.SqlServer | DockerServices.TestHost | DockerServices.TransactionProcessor | + DockerServices.TransactionProcessorAcl; + this.TestingContext.DockerHelper = new DockerHelper(); this.TestingContext.DockerHelper.Logger = logger; + this.TestingContext.Logger = logger; + this.TestingContext.DockerHelper.RequiredDockerServices = dockerServices; + this.TestingContext.Logger.LogInformation("About to Start Global Setup"); + + await Setup.GlobalSetup(this.TestingContext.DockerHelper); + this.TestingContext.DockerHelper.SqlServerContainer = Setup.DatabaseServerContainer; this.TestingContext.DockerHelper.SqlServerNetwork = Setup.DatabaseServerNetwork; this.TestingContext.DockerHelper.DockerCredentials = Setup.DockerCredentials; @@ -52,21 +89,17 @@ public async Task StartSystem() this.TestingContext.Logger = logger; this.TestingContext.Logger.LogInformation("About to Start Containers for Scenario Run"); - - DockerServices dockerServices = DockerServices.CallbackHandler | DockerServices.EstateManagement | DockerServices.EventStore | - DockerServices.FileProcessor | DockerServices.MessagingService | DockerServices.SecurityService | - DockerServices.SqlServer | DockerServices.TestHost | DockerServices.TransactionProcessor | - DockerServices.TransactionProcessorAcl; - await this.TestingContext.DockerHelper.StartContainersForScenarioRun(scenarioName, dockerServices).ConfigureAwait(false); this.TestingContext.Logger.LogInformation("Containers for Scenario Run Started"); } [AfterScenario] - public async Task StopSystem() - { + public async Task StopSystem(){ + + DockerServices sharedDockerServices = DockerServices.SqlServer; + this.TestingContext.Logger.LogInformation("About to Stop Containers for Scenario Run"); - await this.TestingContext.DockerHelper.StopContainersForScenarioRun().ConfigureAwait(false); + await this.TestingContext.DockerHelper.StopContainersForScenarioRun(sharedDockerServices).ConfigureAwait(false); this.TestingContext.Logger.LogInformation("Containers for Scenario Run Stopped"); } } diff --git a/TransactionProcessor.IntegrationTests/Common/Setup.cs b/TransactionProcessor.IntegrationTests/Common/Setup.cs index 10ad1430..26f26f61 100644 --- a/TransactionProcessor.IntegrationTests/Common/Setup.cs +++ b/TransactionProcessor.IntegrationTests/Common/Setup.cs @@ -9,14 +9,15 @@ namespace TransactionProcessor.IntegrationTests.Common using System.IO; using System.Net; using System.Threading; + using System.Threading.Tasks; using Ductus.FluentDocker.Builders; using Ductus.FluentDocker.Services; using Ductus.FluentDocker.Services.Extensions; using global::Shared.Logger; using Microsoft.Data.SqlClient; using NLog; + using Reqnroll; using Shouldly; - using TechTalk.SpecFlow; [Binding] public class Setup @@ -25,23 +26,18 @@ public class Setup public static INetworkService DatabaseServerNetwork; public static (String usename, String password) SqlCredentials = ("sa", "thisisalongpassword123!"); public static (String url, String username, String password) DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland"); - [BeforeTestRun] - protected static void GlobalSetup() + + public static async Task GlobalSetup(DockerHelper dockerHelper) { ShouldlyConfiguration.DefaultTaskTimeout = TimeSpan.FromMinutes(1); - - DockerHelper dockerHelper = new DockerHelper(); - - NlogLogger logger = new NlogLogger(); - logger.Initialise(LogManager.GetLogger("Specflow"), "Specflow"); - LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly); - dockerHelper.Logger = logger; dockerHelper.SqlCredentials = Setup.SqlCredentials; dockerHelper.DockerCredentials = Setup.DockerCredentials; dockerHelper.SqlServerContainerName = "sharedsqlserver"; - Setup.DatabaseServerNetwork = dockerHelper.SetupTestNetwork("sharednetwork", true); - Setup.DatabaseServerContainer = dockerHelper.SetupSqlServerContainer(Setup.DatabaseServerNetwork); + await Retry.For(async () => { + Setup.DatabaseServerNetwork = dockerHelper.SetupTestNetwork("sharednetwork", true); + Setup.DatabaseServerContainer = await dockerHelper.SetupSqlServerContainer(Setup.DatabaseServerNetwork); + }, TimeSpan.FromSeconds(60)); } public static String GetConnectionString(String databaseName) diff --git a/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs b/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs deleted file mode 100644 index dc1e1782..00000000 --- a/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs +++ /dev/null @@ -1,133 +0,0 @@ -namespace TransactionProcessor.IntegrationTests.Common -{ - using System; - using TechTalk.SpecFlow; - - /// - /// - /// - public static class SpecflowTableHelper - { - #region Methods - - /// - /// Gets the boolean value. - /// - /// The row. - /// The key. - /// - public static Boolean GetBooleanValue(TableRow row, - String key) - { - String field = SpecflowTableHelper.GetStringRowValue(row, key); - - return bool.TryParse(field, out Boolean value) && value; - } - - /// - /// Gets the date for date string. - /// - /// The date string. - /// The today. - /// - public static DateTime GetDateForDateString(String dateString, - DateTime today) - { - switch(dateString.ToUpper()) - { - case "TODAY": - return today.Date; - case "YESTERDAY": - return today.AddDays(-1).Date; - case "LASTWEEK": - return today.AddDays(-7).Date; - case "NEXTWEEK": - return today.AddDays(7).Date; - case "LASTMONTH": - return today.AddMonths(-1).Date; - case "LASTYEAR": - return today.AddYears(-1).Date; - case "TOMORROW": - return today.AddDays(1).Date; - default: - return DateTime.Parse(dateString); - } - } - - /// - /// Gets the decimal value. - /// - /// The row. - /// The key. - /// - public static Decimal GetDecimalValue(TableRow row, - String key) - { - String field = SpecflowTableHelper.GetStringRowValue(row, key); - - return decimal.TryParse(field, out Decimal value) ? value : -1; - } - - /// - /// Gets the enum value. - /// - /// - /// The row. - /// The key. - /// - public static T GetEnumValue(TableRow row, - String key) where T : struct - { - String field = SpecflowTableHelper.GetStringRowValue(row, key); - - return Enum.Parse(field, true); - } - - /// - /// Gets the int value. - /// - /// The row. - /// The key. - /// - public static Int32 GetIntValue(TableRow row, - String key) - { - String field = SpecflowTableHelper.GetStringRowValue(row, key); - - return int.TryParse(field, out Int32 value) ? value : -1; - } - - /// - /// Gets the short value. - /// - /// The row. - /// The key. - /// - public static Int16 GetShortValue(TableRow row, - String key) - { - String field = SpecflowTableHelper.GetStringRowValue(row, key); - - if (short.TryParse(field, out Int16 value)) - { - return value; - } - - return -1; - } - - /// - /// Gets the string row value. - /// - /// The row. - /// The key. - /// - public static String GetStringRowValue(TableRow row, - String key) - { - return row.TryGetValue(key, out String value) ? value : ""; - } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTests/Common/TestingContext.cs b/TransactionProcessor.IntegrationTests/Common/TestingContext.cs index 6797d103..06c0929c 100644 --- a/TransactionProcessor.IntegrationTests/Common/TestingContext.cs +++ b/TransactionProcessor.IntegrationTests/Common/TestingContext.cs @@ -8,10 +8,12 @@ using DataTransferObjects; using EstateManagement.DataTransferObjects.Responses; using EstateManagement.IntegrationTesting.Helpers; + using global::Shared.IntegrationTesting; using global::Shared.Logger; using Newtonsoft.Json; + using Reqnroll; using Shouldly; - using TechTalk.SpecFlow; + using Retry = IntegrationTests.Retry; /// /// @@ -128,9 +130,9 @@ public ClientDetails GetClientDetails(String clientId) /// /// The table row. /// - public EstateDetails GetEstateDetails(TableRow tableRow) + public EstateDetails GetEstateDetails(DataTableRow tableRow) { - String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); EstateDetails estateDetails = null; estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); diff --git a/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs b/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs index a3ece6f1..fd05fff9 100644 --- a/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs @@ -1,8 +1,8 @@ // ------------------------------------------------------------------------------ // -// This code was generated by SpecFlow (https://www.specflow.org/). -// SpecFlow Version:3.9.0.0 -// SpecFlow Generator Version:3.9.0.0 +// This code was generated by Reqnroll (https://www.reqnroll.net/). +// Reqnroll Version:1.0.0.0 +// Reqnroll Generator Version:1.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,19 +12,19 @@ #pragma warning disable namespace TransactionProcessor.IntegrationTests.Features { - using TechTalk.SpecFlow; + using Reqnroll; using System; using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "1.0.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [Xunit.TraitAttribute("Category", "base")] [Xunit.TraitAttribute("Category", "shared")] - public partial class LogonTransactionFeature : object, Xunit.IClassFixture, System.IDisposable + public partial class LogonTransactionFeature : object, Xunit.IClassFixture, Xunit.IAsyncLifetime { - private static TechTalk.SpecFlow.ITestRunner testRunner; + private static Reqnroll.ITestRunner testRunner; private static string[] featureTags = new string[] { "base", @@ -35,55 +35,56 @@ public partial class LogonTransactionFeature : object, Xunit.IClassFixture