Example #1
0
        public void UpdateCartDiscountByIdSetDescription()
        {
            IClient      commerceToolsClient = this.cartDiscountFixture.GetService <IClient>();
            CartDiscount cartDiscount        = this.cartDiscountFixture.CreateCartDiscount();

            string newDescription = TestingUtility.RandomString(20);
            List <UpdateAction <CartDiscount> > updateActions = new List <UpdateAction <CartDiscount> >();
            SetDescriptionUpdateAction          setDescriptionUpdateAction = new SetDescriptionUpdateAction()
            {
                Description = new LocalizedString()
                {
                    { "en", newDescription }
                }
            };

            updateActions.Add(setDescriptionUpdateAction);

            CartDiscount retrievedCartDiscount = commerceToolsClient
                                                 .ExecuteAsync(new UpdateByIdCommand <CartDiscount>(new Guid(cartDiscount.Id), cartDiscount.Version,
                                                                                                    updateActions))
                                                 .Result;

            this.cartDiscountFixture.CartDiscountsToDelete.Add(retrievedCartDiscount);
            Assert.Equal(newDescription, retrievedCartDiscount.Description["en"]);
        }
Example #2
0
        public async Task UpdateCartDiscountSetDescription()
        {
            await WithUpdateableCartDiscount(client, async cartDiscount =>
            {
                var newDescription = new LocalizedString {
                    { "en", TestingUtility.RandomString() }
                };
                var updateActions = new List <UpdateAction <CartDiscount> >();
                var action        = new SetDescriptionUpdateAction {
                    Description = newDescription
                };
                updateActions.Add(action);

                var updatedCartDiscount = await client
                                          .ExecuteAsync(new UpdateByIdCommand <CartDiscount>(cartDiscount, updateActions));

                Assert.Equal(newDescription["en"], updatedCartDiscount.Description["en"]);
                return(updatedCartDiscount);
            });
        }