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

            string name = this.cartDiscountFixture.RandomString(10);
            List <UpdateAction <CartDiscount> > updateActions = new List <UpdateAction <CartDiscount> >();
            ChangeNameUpdateAction changeNameUpdateAction     = new ChangeNameUpdateAction()
            {
                Name = new LocalizedString()
                {
                    { "en", name }
                }
            };

            updateActions.Add(changeNameUpdateAction);

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

            this.cartDiscountFixture.CartDiscountsToDelete.Add(retrievedCartDiscount);
            Assert.Equal(name, retrievedCartDiscount.Name["en"]);
        }
        public async Task UpdateProjectChangeName()
        {
            await WithCurrentProject(client,
                                     async project =>
            {
                Assert.NotNull(project);
                var oldName = project.Name;
                var newName = oldName + "-New";

                var action = new ChangeNameUpdateAction
                {
                    Name = newName
                };

                var updatedProject = await
                                     TryToUpdateCurrentProject(client, project, action.ToList());

                Assert.Equal(newName, updatedProject.Name);

                // then undo this change again
                action = new ChangeNameUpdateAction
                {
                    Name = oldName
                };
                var projectWithOriginalName = await
                                              TryToUpdateCurrentProject(client, project, action.ToList());
                Assert.Equal(oldName, projectWithOriginalName.Name);
            });
        }
        public async Task UpdateShoppingListInStoreByKeyChangeName()
        {
            var newName = new LocalizedString {
                { "en", TestingUtility.RandomString() }
            };

            await WithStore(client, async store =>
            {
                await WithUpdateableShoppingList(client,
                                                 draft =>
                                                 DefaultShoppingListDraftInStore(DefaultShoppingListDraft(draft),
                                                                                 store.ToKeyResourceIdentifier()),
                                                 async shoppingList =>
                {
                    Assert.NotNull(shoppingList.Store);
                    Assert.Equal(store.Key, shoppingList.Store.Key);
                    var action = new ChangeNameUpdateAction
                    {
                        Name = newName
                    };

                    var updatedShoppingList = await client
                                              .ExecuteAsync(shoppingList.UpdateByKey(
                                                                actions => actions.AddUpdate(action)).InStore(store.Key));

                    Assert.NotNull(updatedShoppingList.Store);
                    Assert.Equal(store.Key, updatedShoppingList.Store.Key);
                    Assert.Equal(newName["en"], updatedShoppingList.Name["en"]);
                    return(updatedShoppingList);
                });
            });
        }
Exemple #4
0
        public async Task UpdateCustomerGroupByKeyChangeName()
        {
            await WithUpdateableCustomerGroup(client, async customerGroup =>
            {
                var name   = TestingUtility.RandomString();
                var action = new ChangeNameUpdateAction {
                    Name = name
                };

                var updatedCustomerGroup = await client
                                           .ExecuteAsync(customerGroup.UpdateByKey(actions => actions.AddUpdate(action)));

                Assert.Equal(name, updatedCustomerGroup.Name);
                return(updatedCustomerGroup);
            });
        }
        public async Task UpdateShippingMethodChangeName()
        {
            await WithUpdateableShippingMethod(client, async shippingMethod =>
            {
                var newName       = TestingUtility.RandomString();
                var updateActions = new List <UpdateAction <ShippingMethod> >();
                var action        = new ChangeNameUpdateAction {
                    Name = newName
                };
                updateActions.Add(action);

                var updatedShippingMethod = await client
                                            .ExecuteAsync(new UpdateByIdCommand <ShippingMethod>(shippingMethod, updateActions));

                Assert.Equal(newName, updatedShippingMethod.Name);
                return(updatedShippingMethod);
            });
        }
        public async Task UpdateProductTypeChangeName()
        {
            var newName = $"UpdateProductTypeChangeName-{TestingUtility.RandomString()}";

            await WithUpdateableProductType(client, async productType =>
            {
                var updateActions    = new List <UpdateAction <ProductType> >();
                var changeNameAction = new ChangeNameUpdateAction {
                    Name = newName
                };
                updateActions.Add(changeNameAction);

                var updatedProductType = await client
                                         .ExecuteAsync(new UpdateByIdCommand <ProductType>(productType, updateActions));

                Assert.Equal(newName, updatedProductType.Name);
                return(updatedProductType);
            });
        }
        public void UpdateCustomerGroupByIdChangeName()
        {
            IClient       commerceToolsClient = this.customerGroupFixture.GetService <IClient>();
            CustomerGroup customerGroup       = this.customerGroupFixture.CreateCustomerGroup();
            string        name = TestingUtility.RandomString(10);
            List <UpdateAction <CustomerGroup> > updateActions = new List <UpdateAction <CustomerGroup> >();
            ChangeNameUpdateAction changeNameUpdateAction      = new ChangeNameUpdateAction()
            {
                Name = name
            };

            updateActions.Add(changeNameUpdateAction);
            CustomerGroup retrievedCustomerGroup = commerceToolsClient
                                                   .ExecuteAsync(new UpdateByIdCommand <CustomerGroup>(new Guid(customerGroup.Id), customerGroup.Version,
                                                                                                       updateActions)).Result;

            this.customerGroupFixture.CustomerGroupsToDelete.Add(retrievedCustomerGroup);
            Assert.Equal(name, retrievedCustomerGroup.Name);
        }
Exemple #8
0
        public async Task UpdateCategoryByKeyChangeName()
        {
            await WithUpdateableCategory(client, async category =>
            {
                var name   = TestingUtility.RandomString();
                var action = new ChangeNameUpdateAction
                {
                    Name = new LocalizedString {
                        { "en", name }
                    }
                };

                var updatedCategory = await client
                                      .ExecuteAsync(category.UpdateByKey(actions => actions.AddUpdate(action)));

                Assert.Equal(name, updatedCategory.Name["en"]);
                return(updatedCategory);
            });
        }
Exemple #9
0
        public async Task UpdateProductDiscountChangeName()
        {
            await WithUpdateableProductDiscount(client, async productDiscount =>
            {
                var name   = TestingUtility.RandomString();
                var action = new ChangeNameUpdateAction
                {
                    Name = new LocalizedString()
                    {
                        { "en", name }
                    }
                };

                var updatedProductDiscount = await client
                                             .ExecuteAsync(productDiscount.UpdateByKey(actions => actions.AddUpdate(action)));

                Assert.Equal(name, updatedProductDiscount.Name["en"]);
                return(updatedProductDiscount);
            });
        }
Exemple #10
0
        public async Task UpdateTaxCategoryChangeName()
        {
            var newName = $"UpdateTaxCategoryChangeName-{TestingUtility.RandomString()}";

            await WithUpdateableTaxCategory(client, async taxCategory =>
            {
                var updateActions = new List <UpdateAction <TaxCategory> >();
                var setKeyAction  = new ChangeNameUpdateAction {
                    Name = newName
                };
                updateActions.Add(setKeyAction);

                var updatedTaxCategory = await client
                                         .ExecuteAsync(new UpdateByKeyCommand <TaxCategory>(taxCategory.Key, taxCategory.Version,
                                                                                            updateActions));

                Assert.Equal(newName, updatedTaxCategory.Name);
                return(updatedTaxCategory);
            });
        }
Exemple #11
0
        public async Task UpdateCartDiscountChangeName()
        {
            await WithUpdateableCartDiscount(client, async cartDiscount =>
            {
                var newName = new LocalizedString {
                    { "en", TestingUtility.RandomString() }
                };
                var updateActions = new List <UpdateAction <CartDiscount> >();
                var action        = new ChangeNameUpdateAction {
                    Name = newName
                };
                updateActions.Add(action);

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

                Assert.Equal(newName["en"], updatedCartDiscount.Name["en"]);
                return(updatedCartDiscount);
            });
        }
Exemple #12
0
        public void UpdateTypeByKeyChangeName()
        {
            IClient commerceToolsClient = this.typeFixture.GetService <IClient>();
            Type    type = this.typeFixture.CreateType();
            List <UpdateAction <Type> > updateActions = new List <UpdateAction <Type> >();
            string newName = TestingUtility.RandomString(10);
            ChangeNameUpdateAction changeNameUpdateAction = new ChangeNameUpdateAction()
            {
                Name = new LocalizedString()
                {
                    { "en", newName }
                }
            };

            updateActions.Add(changeNameUpdateAction);
            Type retrievedType = commerceToolsClient.ExecuteAsync(new UpdateByKeyCommand <Type>(type.Key, type.Version, updateActions)).Result;

            this.typeFixture.TypesToDelete.Add(retrievedType);
            Assert.Equal(newName, retrievedType.Name["en"]);
        }
Exemple #13
0
        public void UpdateProductByKeyChangeName()
        {
            IClient commerceToolsClient = this.productFixture.GetService <IClient>();
            Product product             = this.productFixture.CreateProduct();
            string  name = this.productFixture.RandomString(10);
            List <UpdateAction <Product> > updateActions          = new List <UpdateAction <Product> >();
            ChangeNameUpdateAction         changeNameUpdateAction = new ChangeNameUpdateAction()
            {
                Name = new LocalizedString()
                {
                    { "en", name }
                }
            };

            updateActions.Add(changeNameUpdateAction);
            Product retrievedProduct = commerceToolsClient
                                       .ExecuteAsync(new UpdateByKeyCommand <Product>(product.Key, product.Version, updateActions)).Result;

            this.productFixture.ProductsToDelete.Add(retrievedProduct);
            Assert.Equal(name, retrievedProduct.MasterData.Staged.Name["en"]);
        }
Exemple #14
0
        public async Task UpdateTypeChangeName()
        {
            var newName = new LocalizedString {
                { "en", $"UpdateTypeChangeName-{TestingUtility.RandomString()}" }
            };

            await WithUpdateableType(client, async type =>
            {
                var updateActions    = new List <UpdateAction <Type> >();
                var changeNameAction = new ChangeNameUpdateAction {
                    Name = newName
                };
                updateActions.Add(changeNameAction);

                var updatedType = await client
                                  .ExecuteAsync(new UpdateByIdCommand <Type>(type, updateActions));

                Assert.Equal(newName["en"], updatedType.Name["en"]);
                return(updatedType);
            });
        }
        public async Task UpdateShoppingListByKeyChangeName()
        {
            await WithUpdateableShoppingList(client, async shoppingList =>
            {
                var newName = new LocalizedString {
                    { "en", TestingUtility.RandomString() }
                };
                var updateActions = new List <UpdateAction <ShoppingList> >();
                var action        = new ChangeNameUpdateAction
                {
                    Name = newName
                };
                updateActions.Add(action);

                var updatedShoppingList = await client
                                          .ExecuteAsync(new UpdateByKeyCommand <ShoppingList>(shoppingList.Key, shoppingList.Version, updateActions));

                Assert.Equal(newName["en"], updatedShoppingList.Name["en"]);
                return(updatedShoppingList);
            });
        }