public async Task WhenIRedeemTheFollowingVouchersTheBalanceWillBeAsExpected(Table table) { foreach (TableRow tableRow in table.Rows) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); String operatorIdentifier = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName"); Guid transactionId = Guid.Parse(SpecflowTableHelper.GetStringRowValue(tableRow, "TransactionId")); Decimal balance = SpecflowTableHelper.GetDecimalValue(tableRow, "Balance"); (Guid transactionId, Decimal value, String voucherCode, Guid voucherId)voucher = estateDetails.GetVoucher(operatorIdentifier, transactionId); // Build URI String uri = $"api/vouchers?applicationVersion=1.0.0&voucherCode={voucher.voucherCode}"; String accessToken = estateDetails.GetVoucherRedemptionUserToken(operatorIdentifier); StringContent content = new StringContent(String.Empty); this.TestingContext.DockerHelper.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); HttpResponseMessage response = await this.TestingContext.DockerHelper.HttpClient.PutAsync(uri, content, CancellationToken.None).ConfigureAwait(false); response.IsSuccessStatusCode.ShouldBeTrue(); RedeemVoucherResponseMessage redeemVoucherResponse = JsonConvert.DeserializeObject <RedeemVoucherResponseMessage>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)); redeemVoucherResponse.Balance.ShouldBe(balance); redeemVoucherResponse.VoucherCode.ShouldBe(voucher.voucherCode); } }
public async Task WhenIGetTheFileForEstateTheFollowingFileInformationIsReturned(string fileName, string estateName, Table table) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); Guid fileId = estateDetails.GetFileId(fileName); TableRow tableRow = table.Rows.First(); Boolean processingCompleted = SpecflowTableHelper.GetBooleanValue(tableRow, "ProcessingCompleted"); Int32 numberOfLines = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfLines"); Int32 totaLines = SpecflowTableHelper.GetIntValue(tableRow, "TotaLines"); Int32 successfulLines = SpecflowTableHelper.GetIntValue(tableRow, "SuccessfulLines"); Int32 ignoredLines = SpecflowTableHelper.GetIntValue(tableRow, "IgnoredLines"); Int32 failedLines = SpecflowTableHelper.GetIntValue(tableRow, "FailedLines"); Int32 notProcessedLines = SpecflowTableHelper.GetIntValue(tableRow, "NotProcessedLines"); await Retry.For(async() => { var fileDetails = await this.GetFile(estateName, fileId, CancellationToken.None); fileDetails.ProcessingCompleted.ShouldBe(processingCompleted); fileDetails.FileLines.Count.ShouldBe(numberOfLines); fileDetails.ProcessingSummary.TotalLines.ShouldBe(totaLines); fileDetails.ProcessingSummary.SuccessfullyProcessedLines.ShouldBe(successfulLines); fileDetails.ProcessingSummary.IgnoredLines.ShouldBe(ignoredLines); fileDetails.ProcessingSummary.FailedLines.ShouldBe(failedLines); fileDetails.ProcessingSummary.NotProcessedLines.ShouldBe(notProcessedLines); }, TimeSpan.FromMinutes(4), TimeSpan.FromSeconds(30)); }
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 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}"); } }
public async Task WhenICreateTheFollowingEstates(Table table) { foreach (TableRow tableRow in table.Rows) { String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); CreateEstateRequest createEstateRequest = new CreateEstateRequest { EstateId = Guid.NewGuid(), EstateName = estateName }; CreateEstateResponse response = null; try { response = await this.TestingContext.DockerHelper.EstateClient .CreateEstate(this.TestingContext.AccessToken, createEstateRequest, CancellationToken.None) .ConfigureAwait(false); } catch (Exception e) { this.TestingContext.DockerHelper.Logger.LogInformation(e.Message); if (e.InnerException != null) { this.TestingContext.DockerHelper.Logger.LogInformation(e.InnerException.Message); if (e.InnerException.InnerException != null) { this.TestingContext.DockerHelper.Logger.LogInformation(e.InnerException.InnerException.Message); } } } response.ShouldNotBeNull(); response.EstateId.ShouldNotBe(Guid.Empty); // Cache the estate id this.TestingContext.AddEstateDetails(response.EstateId, estateName); //this.TestingContext.Logger.LogInformation($"Estate {estateName} created with Id {response.EstateId}"); } foreach (TableRow tableRow in table.Rows) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); EstateResponse estate = null; await Retry.For(async() => { estate = await this.TestingContext.DockerHelper.EstateClient .GetEstate(this.TestingContext.AccessToken, estateDetails.EstateId, CancellationToken.None).ConfigureAwait(false); }); estate.ShouldNotBeNull(); estate.EstateName.ShouldBe(estateDetails.EstateName); } }
public async Task GivenIAmLoggedInAsWithPasswordForEstateWithClient(String username, String password, String estateName, String clientId) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId); TokenResponse tokenResponse = await this.TestingContext.DockerHelper.SecurityServiceClient .GetToken(username, password, clientId, clientDetails.ClientSecret, CancellationToken.None).ConfigureAwait(false); estateDetails.AddVoucherRedemptionUserToken("Voucher", username, tokenResponse.AccessToken); }
public async Task WhenICreateTheFollowingEstates(Table table) { foreach (TableRow tableRow in table.Rows) { String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName"); CreateEstateRequest createEstateRequest = new CreateEstateRequest { EstateId = Guid.NewGuid(), EstateName = estateName }; CreateEstateResponse response = await this.TestingContext.DockerHelper.EstateClient .CreateEstate(this.TestingContext.AccessToken, createEstateRequest, CancellationToken.None) .ConfigureAwait(false); response.ShouldNotBeNull(); response.EstateId.ShouldNotBe(Guid.Empty); // Cache the estate id this.TestingContext.AddEstateDetails(response.EstateId, estateName); this.TestingContext.Logger.LogInformation($"Estate {estateName} created with Id {response.EstateId}"); EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); // Setup the subscriptions for the estate await Retry.For(async() => { await this.TestingContext.DockerHelper.PopulateSubscriptionServiceConfiguration(estateName).ConfigureAwait(false); }, retryFor : TimeSpan.FromMinutes(2), retryInterval : TimeSpan.FromSeconds(30)); EstateResponse estate = null; await Retry.For(async() => { estate = await this.TestingContext.DockerHelper.EstateClient .GetEstate(this.TestingContext.AccessToken, estateDetails.EstateId, CancellationToken.None).ConfigureAwait(false); estate.ShouldNotBeNull(); }, TimeSpan.FromMinutes(2)).ConfigureAwait(false); estate.EstateName.ShouldBe(estateDetails.EstateName); } }
public async Task WhenIGetTheFileForEstateTheFollowingFileLinesAreReturned(string fileName, string estateName, Table table) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); Guid fileId = estateDetails.GetFileId(fileName); var fileDetails = await this.GetFile(estateName, fileId, CancellationToken.None); foreach (TableRow tableRow in table.Rows) { var lineNumber = SpecflowTableHelper.GetIntValue(tableRow, "LineNumber"); var lineData = SpecflowTableHelper.GetStringRowValue(tableRow, "Data"); var processingResult = SpecflowTableHelper.GetEnumValue <FileLineProcessingResult>(tableRow, "Result"); var lineToVerify = fileDetails.FileLines.SingleOrDefault(fl => fl.LineNumber == lineNumber); lineToVerify.ShouldNotBeNull(); lineToVerify.LineData.ShouldBe(lineData); lineToVerify.ProcessingResult.ShouldBe(processingResult); } }
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 GivenIHaveCreatedTheFollowingSecurityUsers(Table table) { foreach (TableRow tableRow in table.Rows) { String roleName = SpecflowTableHelper.GetStringRowValue(tableRow, "RoleName"); String emailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "EmailAddress"); String password = SpecflowTableHelper.GetStringRowValue(tableRow, "Password"); String givenName = SpecflowTableHelper.GetStringRowValue(tableRow, "GivenName"); String familyName = SpecflowTableHelper.GetStringRowValue(tableRow, "FamilyName"); EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); CreateUserRequest createUserRequest = new CreateUserRequest { EmailAddress = emailAddress, FamilyName = familyName, GivenName = givenName, MiddleName = String.Empty, Password = password, PhoneNumber = "123456789", Roles = new List <String> { roleName }, Claims = new Dictionary <String, String> { { "estateId", estateDetails.EstateId.ToString() }, { "contractId", estateDetails.EstateId.ToString() } } }; CreateUserResponse createUserResponse = await this.TestingContext.DockerHelper.SecurityServiceClient.CreateUser(createUserRequest, CancellationToken.None) .ConfigureAwait(false); createUserResponse.UserId.ShouldNotBe(Guid.Empty); // TODO: this needs to be dynamic :| estateDetails.AddVoucherRedemptionUser("Voucher", emailAddress, password); } }
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 WhenIIssueTheFollowingVouchers(Table table) { foreach (TableRow tableRow in table.Rows) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); IssueVoucherRequest request = new IssueVoucherRequest { Value = SpecflowTableHelper.GetDecimalValue(tableRow, "Value"), RecipientEmail = SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientEmail"), RecipientMobile = SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientMobile"), EstateId = estateDetails.EstateId, OperatorIdentifier = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName"), TransactionId = Guid.Parse(SpecflowTableHelper.GetStringRowValue(tableRow, "TransactionId")) }; IssueVoucherResponse response = await this.TestingContext.DockerHelper.VoucherManagementClient.IssueVoucher(this.TestingContext.AccessToken, request, CancellationToken.None) .ConfigureAwait(false); response.VoucherId.ShouldNotBe(Guid.Empty); await Retry.For(async() => { var v = await this.TestingContext.DockerHelper.VoucherManagementClient .GetVoucher(this.TestingContext.AccessToken, estateDetails.EstateId, response.VoucherCode, CancellationToken.None) .ConfigureAwait(false); v.ShouldNotBeNull(); }); estateDetails.AddVoucher(request.OperatorIdentifier, request.Value, request.TransactionId, response.VoucherCode, response.VoucherId); } }
public async Task WhenIGetTheImportLogForTheFollowingFileInformationIsReturned(string estateName, string startDate, Table table) { EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); FileImportLogList importLogList = await this.GetFileImportLogList(estateName, startDate, startDate, CancellationToken.None); importLogList.FileImportLogs.ShouldHaveSingleItem(); var fileImportLog = await this.GetFileImportLog(estateName, importLogList.FileImportLogs.Single().FileImportLogId, CancellationToken.None); foreach (TableRow tableRow in table.Rows) { //| MerchantName | OriginalFileName | NumberOfLines | var merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); var originalFileName = SpecflowTableHelper.GetStringRowValue(tableRow, "OriginalFileName"); var merchantId = this.TestingContext.GetEstateDetails(estateName).GetMerchantId(merchantName); var file = fileImportLog.Files.SingleOrDefault(f => f.OriginalFileName == originalFileName && f.MerchantId == merchantId); file.ShouldNotBeNull(); estateDetails.AddFileImportLogFile(file); } }
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); }); } }
public async Task WhenICreateTheFollowingSecurityUsers(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); if (tableRow.ContainsKey("EstateName") && tableRow.ContainsKey("MerchantName") == false) { // Creating an Estate User CreateEstateUserRequest createEstateUserRequest = new CreateEstateUserRequest { EmailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "EmailAddress"), FamilyName = SpecflowTableHelper.GetStringRowValue(tableRow, "FamilyName"), GivenName = SpecflowTableHelper.GetStringRowValue(tableRow, "GivenName"), MiddleName = SpecflowTableHelper.GetStringRowValue(tableRow, "MiddleName"), Password = SpecflowTableHelper.GetStringRowValue(tableRow, "Password") }; CreateEstateUserResponse createEstateUserResponse = await this.TestingContext.DockerHelper.EstateClient.CreateEstateUser(this.TestingContext.AccessToken, estateDetails.EstateId, createEstateUserRequest, CancellationToken.None); createEstateUserResponse.EstateId.ShouldBe(estateDetails.EstateId); createEstateUserResponse.UserId.ShouldNotBe(Guid.Empty); estateDetails.SetEstateUser(createEstateUserRequest.EmailAddress, createEstateUserRequest.Password); //this.TestingContext.Logger.LogInformation($"Security user {createEstateUserRequest.EmailAddress} assigned to Estate {estateDetails.EstateName}"); } else if (tableRow.ContainsKey("MerchantName")) { // Creating a merchant user String token = this.TestingContext.AccessToken; if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) { token = estateDetails.AccessToken; } // lookup the merchant id based on the name in the table String merchantName = SpecflowTableHelper.GetStringRowValue(tableRow, "MerchantName"); Guid merchantId = estateDetails.GetMerchantId(merchantName); CreateMerchantUserRequest createMerchantUserRequest = new CreateMerchantUserRequest { EmailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "EmailAddress"), FamilyName = SpecflowTableHelper.GetStringRowValue(tableRow, "FamilyName"), GivenName = SpecflowTableHelper.GetStringRowValue(tableRow, "GivenName"), MiddleName = SpecflowTableHelper.GetStringRowValue(tableRow, "MiddleName"), Password = SpecflowTableHelper.GetStringRowValue(tableRow, "Password") }; CreateMerchantUserResponse createMerchantUserResponse = await this.TestingContext.DockerHelper.EstateClient.CreateMerchantUser(token, estateDetails.EstateId, merchantId, createMerchantUserRequest, CancellationToken.None); createMerchantUserResponse.EstateId.ShouldBe(estateDetails.EstateId); createMerchantUserResponse.MerchantId.ShouldBe(merchantId); createMerchantUserResponse.UserId.ShouldNotBe(Guid.Empty); estateDetails.AddMerchantUser(merchantName, createMerchantUserRequest.EmailAddress, createMerchantUserRequest.Password); //this.TestingContext.Logger.LogInformation($"Security user {createMerchantUserRequest.EmailAddress} assigned to Merchant {merchantName}"); } } }