public async Task ShouldSetCustomerIdAsync() { CustomerDraft customerDraft = Helper.GetTestCustomerDraft(); Response <CustomerCreatedMessage> customerResponse = await _client.Customers().CreateCustomerAsync(customerDraft); Assert.True(customerResponse.Success); CustomerCreatedMessage customerCreatedMessage = customerResponse.Result; Assert.NotNull(customerCreatedMessage.Customer); Customer customer = customerCreatedMessage.Customer; SetCustomerIdAction setCustomerIdAction = new SetCustomerIdAction { CustomerId = customer.Id }; Response <Cart> cartResponse = await _client.Carts().UpdateCartAsync(_testCarts[0], setCustomerIdAction); Assert.True(cartResponse.Success); _testCarts[0] = cartResponse.Result; Assert.NotNull(_testCarts[0].Id); Assert.Equal(_testCarts[0].CustomerId, customer.Id); setCustomerIdAction = new SetCustomerIdAction(); cartResponse = await _client.Carts().UpdateCartAsync(_testCarts[0], setCustomerIdAction); Assert.True(cartResponse.Success); _testCarts[0] = cartResponse.Result; Assert.NotNull(_testCarts[0].Id); Assert.NotEqual(_testCarts[0].CustomerId, customer.Id); await _client.Customers().DeleteCustomerAsync(customer); }
public async Task ShouldUpdateCartAsync() { CustomerDraft customerDraft = Helper.GetTestCustomerDraft(); Response <CustomerCreatedMessage> messageResponse = await _client.Customers().CreateCustomerAsync(customerDraft); Assert.IsTrue(messageResponse.Success); CustomerCreatedMessage customerCreatedMessage = messageResponse.Result; Assert.NotNull(customerCreatedMessage.Customer); Customer customer = customerCreatedMessage.Customer; Assert.NotNull(customer.Id); SetCustomerIdAction setCustomerIdAction = new SetCustomerIdAction(); setCustomerIdAction.CustomerId = customer.Id; GenericAction recalculateAction = new GenericAction("recalculate"); List <UpdateAction> actions = new List <UpdateAction>(); actions.Add(setCustomerIdAction); actions.Add(recalculateAction); Response <Cart> cartResponse = await _client.Carts().UpdateCartAsync(_testCarts[0], actions); Assert.IsTrue(cartResponse.Success); _testCarts[0] = cartResponse.Result; Assert.NotNull(_testCarts[0].Id); Assert.AreEqual(_testCarts[0].CustomerId, customer.Id); await _client.Customers().DeleteCustomerAsync(customer.Id, customer.Version); }