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 void WhenIEnterTheFollowingTopupDetails(Table table) { table.Rows.ShouldHaveSingleItem(); TableRow topupDetails = table.Rows.Single(); String customerMobileNumber = SpecflowTableHelper.GetStringRowValue(topupDetails, "CustomerMobileNumber"); Decimal topupAmount = SpecflowTableHelper.GetDecimalValue(topupDetails, "TopupAmount"); this.MobileTopupPerformTopupPage.EnterCustomerMobileNumber(customerMobileNumber); this.MobileTopupPerformTopupPage.EnterTopupAmount(topupAmount); }
public async Task GivenTheFollowingVouchersHaveBeenIssued(Table table) { foreach (TableRow tableRow in table.Rows) { //| VoucherCode | VoucherValue | RecipientEmail | RecipientMobile | String voucherCode = SpecflowTableHelper.GetStringRowValue(tableRow, "VoucherCode"); Decimal voucherValue = SpecflowTableHelper.GetDecimalValue(tableRow, "VoucherValue"); String recipientEmail = String.IsNullOrEmpty(SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientEmail")) ? null : SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientEmail"); String recipientMobile = String.IsNullOrEmpty(SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientMobile")) ? null : SpecflowTableHelper.GetStringRowValue(tableRow, "RecipientMobile"); Voucher voucher = new Voucher { Balance = voucherValue, Barcode = String.Empty, // TODO: Generate a barcode EstateId = Guid.Parse("347C8CD4-A194-4115-A36F-A75A5E24C49B"), ContractId = Guid.Parse("FC3E5F36-54AA-4BA2-8BF8-5391ACE4BD4B"), ExpiryDate = DateTime.Now.AddDays(30), GeneratedDateTime = DateTime.Now, IsGenerated = true, IsIssued = true, IsRedeemed = false, IssuedDateTime = DateTime.Now.AddSeconds(5), Message = String.Empty, RecipientEmail = recipientEmail, RecipientMobile = recipientMobile, RedeemedDateTime = DateTime.MinValue, TransactionId = Guid.NewGuid(), Value = voucherValue, VoucherCode = voucherCode, VoucherId = Guid.NewGuid() }; await this.Backdoor.AddTestVoucher(voucher); this.TestingContext.Vouchers.Add(voucher); } }
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); } }