public async Task UpdateCustomerAsync_WhenUpdatingCountryForUserWithNoAddress_OnlyCountryIsUpdated() { //Arrange var stripeCustomerRepositoryMock = new StripeCustomerRepositoryMock(); var stripeCheckoutSessionRepositoryMock = new StripeCheckoutSessionRepositoryMock(); var stripeBillingPortalSessionRepositoryMock = new StripeBillingPortalSessionRepositoryMock(); var userManagementServiceMock = new UserManagementServiceMock(); var priceNameToIdMapper = new DevPriceNameToIdMapper(); StripePaymentService stripePaymentService = new StripePaymentService(stripeCustomerRepositoryMock, stripeCheckoutSessionRepositoryMock, stripeBillingPortalSessionRepositoryMock, userManagementServiceMock, priceNameToIdMapper); string customerId = "cus_id1"; string country = "PL"; var updatedCustomer = new UpdateCustomerDto(customerId, country); //Act var returnedCustomer = await stripePaymentService.UpdateCustomerAsync(updatedCustomer); //Assert Assert.Equal(country, returnedCustomer.Country); Assert.Null(returnedCustomer.City); Assert.Null(returnedCustomer.PostalCode); Assert.Null(returnedCustomer.Line1); Assert.Null(returnedCustomer.Line2); Assert.Null(returnedCustomer.State); }
public async Task UpdateCustomerAsync_WhenUpdatingWholeAddress_EveryAddressPropertyIsPopulated() { //Arrange var stripeCustomerRepositoryMock = new StripeCustomerRepositoryMock(); var stripeCheckoutSessionRepositoryMock = new StripeCheckoutSessionRepositoryMock(); var stripeBillingPortalSessionRepositoryMock = new StripeBillingPortalSessionRepositoryMock(); var userManagementServiceMock = new UserManagementServiceMock(); var priceNameToIdMapper = new DevPriceNameToIdMapper(); StripePaymentService stripePaymentService = new StripePaymentService(stripeCustomerRepositoryMock, stripeCheckoutSessionRepositoryMock, stripeBillingPortalSessionRepositoryMock, userManagementServiceMock, priceNameToIdMapper); string customerId = "cus_id1"; string country = "PL"; string city = "Lodz"; string postalCode = "90-608"; string line1 = "Piotrkowska 60/25"; string line2 = ""; string state = ""; var updatedCustomer = new UpdateCustomerDto(customerId, country) { City = city, PostalCode = postalCode, Line1 = line1, Line2 = line2, State = state, }; //Act var returnedCustomer = await stripePaymentService.UpdateCustomerAsync(updatedCustomer); //Assert Assert.Equal(country, returnedCustomer.Country); Assert.Equal(city, returnedCustomer.City); Assert.Equal(postalCode, returnedCustomer.PostalCode); Assert.Equal(line1, returnedCustomer.Line1); Assert.Equal(line2, returnedCustomer.Line2); Assert.Equal(state, returnedCustomer.State); }
[Fact] public async Task UpdateCustomerAsync_WhenUpdatingCountryForUserWithAddress_OnlyCountryPropertyIsUpdated() { //Arrange var stripeCustomerRepositoryMock = new StripeCustomerRepositoryMock(); var stripeCheckoutSessionRepositoryMock = new StripeCheckoutSessionRepositoryMock(); var stripeBillingPortalSessionRepositoryMock = new StripeBillingPortalSessionRepositoryMock(); var userManagementServiceMock = new UserManagementServiceMock(); var priceNameToIdMapper = new DevPriceNameToIdMapper(); StripePaymentService stripePaymentService = new StripePaymentService(stripeCustomerRepositoryMock, stripeCheckoutSessionRepositoryMock, stripeBillingPortalSessionRepositoryMock, userManagementServiceMock, priceNameToIdMapper); string customerId = "cus_id3"; string newCountry = "UK"; string expectedCity = "Lodz"; string expectedPostalCode = "90-608"; string expectedLine1 = "Piotrkowska 60/25"; string expectedLine2 = null; string expectedState = "lodzkie"; var updatedCustomer = new UpdateCustomerDto(customerId, newCountry); //Act var returnedCustomer = await stripePaymentService.UpdateCustomerAsync(updatedCustomer); //Assert Assert.Equal(newCountry, returnedCustomer.Country); Assert.Equal(expectedCity, returnedCustomer.City); Assert.Equal(expectedPostalCode, returnedCustomer.PostalCode); Assert.Equal(expectedLine1, returnedCustomer.Line1); Assert.Equal(expectedLine2, returnedCustomer.Line2); Assert.Equal(expectedState, returnedCustomer.State); }