public async Task WhenIAddTheFollowingTransactionFees(Table table) { foreach (TableRow tableRow in table.Rows) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); String token = this.TestingContext.AccessToken; if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) { token = estateDetails.AccessToken; } String contractName = SpecflowTableHelper.GetStringRowValue(tableRow, "ContractDescription"); String productName = SpecflowTableHelper.GetStringRowValue(tableRow, "ProductName"); Contract contract = estateDetails.GetContract(contractName); Product product = contract.GetProduct(productName); AddTransactionFeeForProductToContractRequest addTransactionFeeForProductToContractRequest = new AddTransactionFeeForProductToContractRequest { Value = SpecflowTableHelper .GetDecimalValue(tableRow, "Value"), Description = SpecflowTableHelper.GetStringRowValue(tableRow, "FeeDescription"), CalculationType = SpecflowTableHelper .GetEnumValue <CalculationType>(tableRow, "CalculationType") }; AddTransactionFeeForProductToContractResponse addTransactionFeeForProductToContractResponse = await this.TestingContext.DockerHelper.EstateClient.AddTransactionFeeForProductToContract(token, estateDetails.EstateId, contract.ContractId, product.ProductId, addTransactionFeeForProductToContractRequest, CancellationToken.None); product.AddTransactionFee(addTransactionFeeForProductToContractResponse.TransactionFeeId, addTransactionFeeForProductToContractRequest.CalculationType, addTransactionFeeForProductToContractRequest.Description, addTransactionFeeForProductToContractRequest.Value); } }
public async Task GivenIMakeTheFollowingManualMerchantDeposits(Table table) { foreach (TableRow tableRow in table.Rows) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); String token = this.TestingContext.AccessToken; if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) { token = estateDetails.AccessToken; } // Lookup the merchant id String merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); Guid merchantId = estateDetails.GetMerchantId(merchantName); // Get current balance MerchantBalanceResponse previousMerchantBalance = await this.TestingContext.DockerHelper.EstateClient.GetMerchantBalance(token, estateDetails.EstateId, merchantId, CancellationToken.None); MakeMerchantDepositRequest makeMerchantDepositRequest = new MakeMerchantDepositRequest { DepositDateTime = SpecflowTableHelper.GetDateForDateString(SpecflowTableHelper.GetStringRowValue(tableRow, "DateTime"), DateTime.Now), Reference = SpecflowTableHelper.GetStringRowValue(tableRow, "Reference"), Amount = SpecflowTableHelper.GetDecimalValue(tableRow, "Amount") }; MakeMerchantDepositResponse makeMerchantDepositResponse = await this.TestingContext.DockerHelper.EstateClient.MakeMerchantDeposit(token, estateDetails.EstateId, merchantId, makeMerchantDepositRequest, CancellationToken.None).ConfigureAwait(false); makeMerchantDepositResponse.EstateId.ShouldBe(estateDetails.EstateId); makeMerchantDepositResponse.MerchantId.ShouldBe(merchantId); makeMerchantDepositResponse.DepositId.ShouldNotBe(Guid.Empty); this.TestingContext.Logger.LogInformation($"Deposit Reference {makeMerchantDepositRequest.Reference} made for Merchant {merchantName}"); // Check the merchant balance await Retry.For(async() => { MerchantBalanceResponse currentMerchantBalance = await this.TestingContext.DockerHelper.EstateClient.GetMerchantBalance(token, estateDetails.EstateId, merchantId, CancellationToken.None); currentMerchantBalance.AvailableBalance.ShouldBe(previousMerchantBalance.AvailableBalance + makeMerchantDepositRequest.Amount); }, TimeSpan.FromMinutes(2)); } }