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); }); } }
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}"); } } }