public async Task UpdateCartDiscountChangeRequiresDiscountCode() { await WithUpdateableCartDiscount(client, async cartDiscount => { var newRequiresDiscountCode = !cartDiscount.RequiresDiscountCode; var updateActions = new List <UpdateAction <CartDiscount> >(); var action = new ChangeRequiresDiscountCodeUpdateAction { RequiresDiscountCode = newRequiresDiscountCode }; updateActions.Add(action); var updatedCartDiscount = await client .ExecuteAsync(new UpdateByIdCommand <CartDiscount>(cartDiscount, updateActions)); Assert.Equal(newRequiresDiscountCode, updatedCartDiscount.RequiresDiscountCode); return(updatedCartDiscount); }); }
public void UpdateCartDiscountByIdChangeRequiresDiscountCode() { IClient commerceToolsClient = this.cartDiscountFixture.GetService <IClient>(); CartDiscount cartDiscount = this.cartDiscountFixture.CreateCartDiscount(); List <UpdateAction <CartDiscount> > updateActions = new List <UpdateAction <CartDiscount> >(); ChangeRequiresDiscountCodeUpdateAction changeRequiresDiscountCode = new ChangeRequiresDiscountCodeUpdateAction() { RequiresDiscountCode = !cartDiscount.RequiresDiscountCode }; updateActions.Add(changeRequiresDiscountCode); CartDiscount retrievedCartDiscount = commerceToolsClient .ExecuteAsync(new UpdateByIdCommand <CartDiscount>(new Guid(cartDiscount.Id), cartDiscount.Version, updateActions)) .Result; this.cartDiscountFixture.CartDiscountsToDelete.Add(retrievedCartDiscount); Assert.NotEqual(retrievedCartDiscount.RequiresDiscountCode, cartDiscount.RequiresDiscountCode); }