public async Task UpdateProductTypeChangeLabelOfLocalizedEnumValue()
        {
            var newLabel = $"enum-Label-{TestingUtility.RandomInt()}";

            await WithUpdateableProductType(client, async productType =>
            {
                Assert.NotEmpty(productType.Attributes);

                var enumAttributeDefinition =
                    productType.Attributes.FirstOrDefault(attribute => attribute.Type.GetType() == typeof(LocalizableEnumAttributeType));

                Assert.NotNull(enumAttributeDefinition);

                var enumAttribute = enumAttributeDefinition.Type as LocalizableEnumAttributeType;

                Assert.NotNull(enumAttribute);
                Assert.NotEmpty(enumAttribute.Values);

                var newEnumValue = new LocalizedEnumValue
                {
                    Key = enumAttribute.Values[0].Key, Label = new LocalizedString {
                        { "en", newLabel }
                    }
                };
                var updateActions = new List <UpdateAction <ProductType> >();
                var changeLocalizedEnumValueLabelAction = new ChangeLocalizedEnumValueLabelUpdateAction
                {
                    AttributeName = enumAttributeDefinition.Name,
                    NewValue      = newEnumValue
                };
                updateActions.Add(changeLocalizedEnumValueLabelAction);

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

                var updatedEnumAttribute =
                    updatedType.Attributes.FirstOrDefault(attribute => attribute.Type.GetType() == typeof(LocalizableEnumAttributeType))?.Type as LocalizableEnumAttributeType;

                Assert.NotNull(updatedEnumAttribute);

                Assert.Contains(updatedEnumAttribute.Values,
                                value => value.Key == newEnumValue.Key && value.Label["en"] == newEnumValue.Label["en"]);
                return(updatedType);
            });
        }
        public async Task UpdateProductTypeAddLocalizableEnumValue()
        {
            var rand = TestingUtility.RandomInt();
            var newLocalizedEnumValue = new LocalizedEnumValue
            {
                Key = $"enum-key-{rand}", Label = new LocalizedString {
                    { "en", $"enum-label-{rand}" }
                }
            };

            await WithUpdateableProductType(client, async productType =>
            {
                Assert.NotEmpty(productType.Attributes);

                var localizedEnumAttribute =
                    productType.Attributes.FirstOrDefault(attribute =>
                                                          attribute.Type.GetType() == typeof(LocalizableEnumAttributeType));

                Assert.NotNull(localizedEnumAttribute);
                var updateActions = new List <UpdateAction <ProductType> >();
                var addLocalizedEnumValueToAttributeAction = new AddLocalizableEnumValueToAttributeDefinitionUpdateAction
                {
                    AttributeName = localizedEnumAttribute.Name,
                    Value         = newLocalizedEnumValue
                };
                updateActions.Add(addLocalizedEnumValueToAttributeAction);

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

                var updatedLocalizedEnumAttribute =
                    updatedType.Attributes.FirstOrDefault(attribute => attribute.Type.GetType() == typeof(LocalizableEnumAttributeType))?.Type as LocalizableEnumAttributeType;

                Assert.NotNull(updatedLocalizedEnumAttribute);

                Assert.Contains(updatedLocalizedEnumAttribute.Values,
                                value => value.Key == newLocalizedEnumValue.Key && value.Label["en"] == newLocalizedEnumValue.Label["en"]);
                return(updatedType);
            });
        }