public async Task GivenICreateAContractWithTheFollowingValues(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 operatorName = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName"); Guid operatorId = estateDetails.GetOperatorId(operatorName); CreateContractRequest createContractRequest = new CreateContractRequest { OperatorId = operatorId, Description = SpecflowTableHelper.GetStringRowValue(tableRow, "ContractDescription") }; CreateContractResponse contractResponse = await this.TestingContext.DockerHelper.EstateClient.CreateContract(token, estateDetails.EstateId, createContractRequest, CancellationToken.None); estateDetails.AddContract(contractResponse.ContractId, createContractRequest.Description, operatorId); } }
public async Task GivenIHaveAssignedTheFollowingDevicesToTheMerchants(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); // Lookup the operator id String deviceIdentifier = SpecflowTableHelper.GetStringRowValue(tableRow, "DeviceIdentifier"); AddMerchantDeviceRequest addMerchantDeviceRequest = new AddMerchantDeviceRequest { DeviceIdentifier = deviceIdentifier }; AddMerchantDeviceResponse addMerchantDeviceResponse = await this.TestingContext.DockerHelper.EstateClient.AddDeviceToMerchant(token, estateDetails.EstateId, merchantId, addMerchantDeviceRequest, CancellationToken.None).ConfigureAwait(false); addMerchantDeviceResponse.EstateId.ShouldBe(estateDetails.EstateId); addMerchantDeviceResponse.MerchantId.ShouldBe(merchantId); addMerchantDeviceResponse.DeviceId.ShouldNotBe(Guid.Empty); this.TestingContext.Logger.LogInformation($"Device {deviceIdentifier} assigned to Merchant {merchantName} Estate {estateDetails.EstateName}"); } }
public async Task WhenICreateTheFollowingOperators(Table table) { foreach (TableRow tableRow in table.Rows) { String operatorName = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName"); Boolean requireCustomMerchantNumber = SpecflowTableHelper.GetBooleanValue(tableRow, "RequireCustomMerchantNumber"); Boolean requireCustomTerminalNumber = SpecflowTableHelper.GetBooleanValue(tableRow, "RequireCustomTerminalNumber"); CreateOperatorRequest createOperatorRequest = new CreateOperatorRequest { Name = operatorName, RequireCustomMerchantNumber = requireCustomMerchantNumber, RequireCustomTerminalNumber = requireCustomTerminalNumber }; // lookup the estate id based on the name in the table EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); CreateOperatorResponse response = await this.TestingContext.DockerHelper.EstateClient.CreateOperator(this.TestingContext.AccessToken, estateDetails.EstateId, createOperatorRequest, CancellationToken.None).ConfigureAwait(false); response.ShouldNotBeNull(); response.EstateId.ShouldNotBe(Guid.Empty); response.OperatorId.ShouldNotBe(Guid.Empty); // Cache the estate id estateDetails.AddOperator(response.OperatorId, operatorName); this.TestingContext.Logger.LogInformation($"Operator {operatorName} created with Id {response.OperatorId} for Estate {estateDetails.EstateName}"); } }
/// <summary> /// Gets the estate details. /// </summary> /// <param name="estateId">The estate identifier.</param> /// <returns></returns> public EstateDetails GetEstateDetails(Guid estateId) { EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateId == estateId); estateDetails.ShouldNotBeNull(); return(estateDetails); }
/// <summary> /// Gets the estate details. /// </summary> /// <param name="estateName">Name of the estate.</param> /// <returns></returns> public EstateDetails GetEstateDetails(String estateName) { EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); estateDetails.ShouldNotBeNull(); return(estateDetails); }
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); } }
/// <summary> /// Gets the estate details. /// </summary> /// <param name="tableRow">The table row.</param> /// <returns></returns> public EstateDetails GetEstateDetails(TableRow tableRow) { String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); EstateDetails estateDetails = null; estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); if (estateDetails == null && estateName == "InvalidEstate") { estateDetails = EstateDetails.Create(Guid.Parse("79902550-64DF-4491-B0C1-4E78943928A3"), estateName); estateDetails.AddMerchant(Guid.Parse("36AA0109-E2E3-4049-9575-F507A887BB1F"), "Test Merchant 1"); this.Estates.Add(estateDetails); } estateDetails.ShouldNotBeNull(); return(estateDetails); }
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)); } }
public async Task WhenICreateTheFollowingProducts(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"); Contract contract = estateDetails.GetContract(contractName); String productValue = SpecflowTableHelper.GetStringRowValue(tableRow, "Value"); AddProductToContractRequest addProductToContractRequest = new AddProductToContractRequest { ProductName = SpecflowTableHelper.GetStringRowValue(tableRow, "ProductName"), DisplayText = SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayText"), Value = null }; if (String.IsNullOrEmpty(productValue) == false) { addProductToContractRequest.Value = Decimal.Parse(productValue); } AddProductToContractResponse addProductToContractResponse = await this.TestingContext.DockerHelper.EstateClient.AddProductToContract(token, estateDetails.EstateId, contract.ContractId, addProductToContractRequest, CancellationToken.None); contract.AddProduct(addProductToContractResponse.ProductId, addProductToContractRequest.ProductName, addProductToContractRequest.DisplayText, addProductToContractRequest.Value); } }
public async Task WhenIAssignTheFollowingOperatorToTheMerchants(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); // Lookup the operator id String operatorName = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName"); Guid operatorId = estateDetails.GetOperatorId(operatorName); AssignOperatorRequest assignOperatorRequest = new AssignOperatorRequest { OperatorId = operatorId, MerchantNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantNumber"), TerminalNumber = SpecflowTableHelper.GetStringRowValue(tableRow, "TerminalNumber"), }; AssignOperatorResponse assignOperatorResponse = await this.TestingContext.DockerHelper.EstateClient.AssignOperatorToMerchant(token, estateDetails.EstateId, merchantId, assignOperatorRequest, CancellationToken.None).ConfigureAwait(false); assignOperatorResponse.EstateId.ShouldBe(estateDetails.EstateId); assignOperatorResponse.MerchantId.ShouldBe(merchantId); assignOperatorResponse.OperatorId.ShouldBe(operatorId); this.TestingContext.Logger.LogInformation($"Operator {operatorName} assigned to Estate {estateDetails.EstateName}"); } }
public async Task WhenICreateTheFollowingMerchants(Table table) { foreach (TableRow tableRow in table.Rows) { // lookup the estate id based on the name in the table EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); String token = this.TestingContext.AccessToken; if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) { token = estateDetails.AccessToken; } String merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); CreateMerchantRequest createMerchantRequest = new CreateMerchantRequest { Name = merchantName, Contact = new Contact { ContactName = SpecflowTableHelper.GetStringRowValue(tableRow, "ContactName"), EmailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "EmailAddress") }, Address = new Address { AddressLine1 = SpecflowTableHelper.GetStringRowValue(tableRow, "AddressLine1"), Town = SpecflowTableHelper.GetStringRowValue(tableRow, "Town"), Region = SpecflowTableHelper.GetStringRowValue(tableRow, "Region"), Country = SpecflowTableHelper.GetStringRowValue(tableRow, "Country") } }; CreateMerchantResponse response = await this.TestingContext.DockerHelper.EstateClient .CreateMerchant(token, estateDetails.EstateId, createMerchantRequest, CancellationToken.None).ConfigureAwait(false); response.ShouldNotBeNull(); response.EstateId.ShouldBe(estateDetails.EstateId); response.MerchantId.ShouldNotBe(Guid.Empty); // Cache the merchant id estateDetails.AddMerchant(response.MerchantId, merchantName); this.TestingContext.Logger.LogInformation($"Merchant {merchantName} created with Id {response.MerchantId} for Estate {estateDetails.EstateName}"); } foreach (TableRow tableRow in table.Rows) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); String merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); Guid merchantId = estateDetails.GetMerchantId(merchantName); String token = this.TestingContext.AccessToken; if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) { token = estateDetails.AccessToken; } await Retry.For(async() => { MerchantResponse merchant = await this.TestingContext.DockerHelper.EstateClient .GetMerchant(token, estateDetails.EstateId, merchantId, CancellationToken.None) .ConfigureAwait(false); merchant.MerchantName.ShouldBe(merchantName); }); } }
/// <summary> /// Adds the estate details. /// </summary> /// <param name="estateId">The estate identifier.</param> /// <param name="estateName">Name of the estate.</param> public void AddEstateDetails(Guid estateId, String estateName) { this.Estates.Add(EstateDetails.Create(estateId, estateName)); }