public Type CreateCustomType()
        {
            Type customType = this.typeFixture.CreateType();

            this.typeFixture.TypesToDelete.Add(customType);
            return(customType);
        }
예제 #2
0
        public Type CreateNewType()
        {
            Type type = this.typeFixture.CreateType();

            this.typeFixture.TypesToDelete.Add(type);
            return(type);
        }
예제 #3
0
        public void DeleteTypeByKey()
        {
            IClient commerceToolsClient = this.typeFixture.GetService <IClient>();
            Type    type          = this.typeFixture.CreateType();
            Type    retrievedType = commerceToolsClient.ExecuteAsync(new DeleteByKeyCommand <Type>(type.Key, type.Version)).Result;

            Assert.Equal(type.Key, retrievedType.Key);
        }
        public Type CreateType()
        {
            TypeDraft typeDraft           = this.CreateTypeDraft();
            IClient   commerceToolsClient = this.GetService <IClient>();
            Type      createdType         = commerceToolsClient.ExecuteAsync(new CreateCommand <Type>(typeDraft)).Result;

            return(createdType);
        }
예제 #5
0
        public void DeserializeStringFieldType()
        {
            ISerializerService serializerService = this.serializationFixture.SerializerService;
            string             serialized        = File.ReadAllText("Resources/FieldTypes/String.json");
            Type deserialized = serializerService.Deserialize <Type>(serialized);

            Assert.IsType <StringFieldType>(deserialized.FieldDefinitions[0].Type);
        }
예제 #6
0
        public void GetTypeByKey()
        {
            IClient commerceToolsClient = this.typeFixture.GetService <IClient>();
            Type    type = this.typeFixture.CreateType();

            this.typeFixture.TypesToDelete.Add(type);
            Type retrievedType = commerceToolsClient.ExecuteAsync(new GetByKeyCommand <Type>(type.Key)).Result;

            Assert.Equal(type.Key, retrievedType.Key);
        }
예제 #7
0
        public void CreateType()
        {
            IClient   commerceToolsClient = this.typeFixture.GetService <IClient>();
            TypeDraft typeDraft           = this.typeFixture.CreateTypeDraft();
            Type      type = commerceToolsClient.ExecuteAsync(new CreateCommand <Type>(typeDraft)).Result;

            // This can also be done in a proxy class wrapping Client that adds types to delete inside
            this.typeFixture.TypesToDelete.Add(type);
            Assert.Equal(typeDraft.Key, type.Key);
        }
예제 #8
0
        public void Dispose()
        {
            IClient commerceToolsClient = this.GetService <IClient>();

            this.TypesToDelete.Reverse();
            foreach (Type type in this.TypesToDelete)
            {
                Type deletedType = commerceToolsClient.ExecuteAsync(new DeleteByIdCommand <Type>(new Guid(type.Id), type.Version)).Result;
            }
        }
        private CustomFieldsDraft CreateCustomFieldsDraft()
        {
            CustomFieldsDraft customFieldsDraft = new CustomFieldsDraft();
            Type type = this.typeFixture.CreateType();

            this.typeFixture.TypesToDelete.Add(type);
            customFieldsDraft.Type = new ResourceIdentifier <Type> {
                Key = type.Key
            };
            customFieldsDraft.Fields = this.CreateNewFields();
            return(customFieldsDraft);
        }
예제 #10
0
        public InventoryEntryDraft CreateInventoryEntryDraftWithCustomFields()
        {
            InventoryEntryDraft draft             = this.GetInventoryEntryDraft();
            CustomFieldsDraft   customFieldsDraft = new CustomFieldsDraft();
            Type type = this.typeFixture.CreateType();

            this.typeFixture.TypesToDelete.Add(type);
            customFieldsDraft.Type = new ResourceIdentifier <Type> {
                Key = type.Key
            };
            customFieldsDraft.Fields = this.CreateNewFields();
            draft.Custom             = customFieldsDraft;
            return(draft);
        }
예제 #11
0
 public static async Task WithUpdateableDiscountCodeWithCustomType(IClient client,
                                                                   Type type, Fields fields, Func <DiscountCode, Task <DiscountCode> > func)
 {
     await WithCartDiscount(client, DefaultCartDiscountDraftRequireDiscountCode, async cartDiscount =>
     {
         var cartDiscounts = new List <Reference <CartDiscount> >()
         {
             new Reference <CartDiscount> {
                 Id = cartDiscount.Id
             }
         };
         await WithUpdateableAsync(client, new DiscountCodeDraft(),
                                   discountCodeDraft =>
                                   DefaultDiscountCodeDraftWithCustomType(discountCodeDraft, cartDiscounts, type, fields), func);
     });
 }
예제 #12
0
        public void UpdateTypeByIdChangeKey()
        {
            IClient commerceToolsClient = this.typeFixture.GetService <IClient>();
            Type    type = this.typeFixture.CreateType();
            List <UpdateAction <Type> > updateActions = new List <UpdateAction <Type> >();
            string newKey = TestingUtility.RandomString(10);
            ChangeKeyUpdateAction changeKeyUpdateAction = new ChangeKeyUpdateAction()
            {
                Key = newKey
            };

            updateActions.Add(changeKeyUpdateAction);
            Type retrievedType = commerceToolsClient.ExecuteAsync(new UpdateByIdCommand <Type>(new Guid(type.Id), type.Version, updateActions)).Result;

            this.typeFixture.TypesToDelete.Add(retrievedType);
            Assert.Equal(newKey, retrievedType.Key);
        }
예제 #13
0
        public void UpdateTypeByIdAddFieldDefinition()
        {
            IClient commerceToolsClient = this.typeFixture.GetService <IClient>();
            Type    type = this.typeFixture.CreateType();
            List <UpdateAction <Type> > updateActions = new List <UpdateAction <Type> >();
            string newKey = TestingUtility.RandomString(10);
            AddFieldDefinitionUpdateAction addFieldDefinitionUpdateAction = new AddFieldDefinitionUpdateAction()
            {
                FieldDefinition = this.typeFixture.CreateNewStringFieldDefinition()
            };

            updateActions.Add(addFieldDefinitionUpdateAction);
            Type retrievedType = commerceToolsClient.ExecuteAsync(new UpdateByIdCommand <Type>(new Guid(type.Id), type.Version, updateActions)).Result;

            this.typeFixture.TypesToDelete.Add(retrievedType);
            Assert.Equal(type.FieldDefinitions.Count + 1, retrievedType.FieldDefinitions.Count);
        }
        public CustomerGroupDraft CreateCustomerGroupDraftWithCustomFields()
        {
            CustomerGroupDraft draft = new CustomerGroupDraft();

            draft.GroupName = TestingUtility.RandomString(10);
            draft.Key       = TestingUtility.RandomString(10);
            CustomFieldsDraft customFieldsDraft = new CustomFieldsDraft();
            Type type = this.typeFixture.CreateType();

            this.typeFixture.TypesToDelete.Add(type);
            customFieldsDraft.Type = new ResourceIdentifier <Type> {
                Key = type.Key
            };
            customFieldsDraft.Fields = this.CreateNewFields();
            draft.Custom             = customFieldsDraft;
            return(draft);
        }
예제 #15
0
        public CategoryDraft GetCategoryDraftWithCustomFields()
        {
            Category relatedCategory = this.CreateCategory(this.GetCategoryDraft());

            this.CategoriesToDelete.Add(relatedCategory);
            CategoryDraft     categoryDraft     = this.GetCategoryDraft();
            CustomFieldsDraft customFieldsDraft = new CustomFieldsDraft();
            Type type = this.typeFixture.CreateType();

            this.typeFixture.TypesToDelete.Add(type);
            customFieldsDraft.Type = new ResourceIdentifier <Type> {
                Key = type.Key
            };
            customFieldsDraft.Fields = new Fields();
            customFieldsDraft.Fields.Add("string-field", "test");
            customFieldsDraft.Fields.Add("localized-string-field",
                                         new LocalizedString()
            {
                { "en", "localized-string-field-value" }
            });
            customFieldsDraft.Fields.Add("enum-field", "enum-key-1");
            customFieldsDraft.Fields.Add("localized-enum-field", "enum-key-1");
            customFieldsDraft.Fields.Add("number-field", 3);
            customFieldsDraft.Fields.Add("boolean-field", true);
            customFieldsDraft.Fields.Add("date-field", new DateTime(2018, 11, 28));
            customFieldsDraft.Fields.Add("date-time-field", new DateTime(2018, 11, 28, 11, 01, 00));
            customFieldsDraft.Fields.Add("time-field", new TimeSpan(11, 01, 00));
            customFieldsDraft.Fields.Add("money-field", new Money()
            {
                CentAmount = 1800, CurrencyCode = "EUR"
            });
            customFieldsDraft.Fields.Add("set-field", new FieldSet <string>()
            {
                "test1", "test2"
            });
            customFieldsDraft.Fields.Add("reference-field", new Reference <Category>()
            {
                Id = relatedCategory.Id
            });
            categoryDraft.Custom = customFieldsDraft;
            return(categoryDraft);
        }
예제 #16
0
        public void UpdateTypeByIdAddEnumToFieldDefinition()
        {
            IClient commerceToolsClient = this.typeFixture.GetService <IClient>();
            Type    type = this.typeFixture.CreateType();
            List <UpdateAction <Type> > updateActions = new List <UpdateAction <Type> >();
            string newKey = TestingUtility.RandomString(10);
            AddEnumToFieldDefinitionUpdateAction addEnumToFieldDefinitionUpdateAction = new AddEnumToFieldDefinitionUpdateAction()
            {
                FieldName = "enum-field", Value = new EnumValue()
                {
                    Key = "new-enum-key", Label = "new-enum-label"
                }
            };

            updateActions.Add(addEnumToFieldDefinitionUpdateAction);
            Type retrievedType = commerceToolsClient.ExecuteAsync(new UpdateByIdCommand <Type>(new Guid(type.Id), type.Version, updateActions)).Result;

            this.typeFixture.TypesToDelete.Add(retrievedType);
            Assert.Equal(type.GetFieldDefinition("enum-field").Type.ToEnumFieldType().Values.Count + 1, retrievedType.GetFieldDefinition("enum-field").Type.ToEnumFieldType().Values.Count);
        }
예제 #17
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"]);
        }
        public static ShoppingListDraft DefaultShoppingListDraftWithCustomType(ShoppingListDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var shoppingListDraft = DefaultShoppingListDraft(draft);

            shoppingListDraft.Custom = customFieldsDraft;

            return(shoppingListDraft);
        }
        public static ChannelDraft DefaultChannelDraftWithCustomType(ChannelDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var channelDraft = DefaultChannelDraft(draft);

            channelDraft.Custom = customFieldsDraft;

            return(channelDraft);
        }
예제 #20
0
        public static DiscountCodeDraft DefaultDiscountCodeDraftWithCustomType(DiscountCodeDraft draft,
                                                                               List <Reference <CartDiscount> > cartDiscounts, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var discountCodeDraft = DefaultDiscountCodeDraft(draft, cartDiscounts);

            discountCodeDraft.Custom = customFieldsDraft;

            return(discountCodeDraft);
        }
        public static ReviewDraft DefaultReviewDraftWithCustomType(ReviewDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var reviewDraft = DefaultReviewDraft(draft);

            reviewDraft.Custom = customFieldsDraft;

            return(reviewDraft);
        }