public static async Task WithUpdateableShoppingListWithTextLineItemWithCustomFields(IClient client, long quantity, Func <ShoppingList, Task <ShoppingList> > func)
 {
     await WithType(client, async type =>
     {
         var fields            = CreateNewFields();
         var customFieldsDraft = new CustomFieldsDraft
         {
             Type   = type.ToKeyResourceIdentifier(),
             Fields = fields
         };
         var textLineItemDraft = new TextLineItemDraft
         {
             Quantity = quantity,
             Name     = new LocalizedString {
                 { "en", TestingUtility.RandomString() }
             },
             Custom = customFieldsDraft
         };
         var shoppingListDraft           = new ShoppingListDraft();
         shoppingListDraft.TextLineItems = new List <TextLineItemDraft> {
             textLineItemDraft
         };
         await WithUpdateableAsync(client, shoppingListDraft, DefaultShoppingListDraft, func);
     });
 }
 public static async Task WithUpdateableShoppingListWithLineItemWithCustomFields(IClient client, long quantity, Func <ShoppingList, Task <ShoppingList> > func)
 {
     await WithType(client, async type =>
     {
         await WithProduct(client, async product =>
         {
             var fields            = CreateNewFields();
             var customFieldsDraft = new CustomFieldsDraft
             {
                 Type   = type.ToKeyResourceIdentifier(),
                 Fields = fields
             };
             var lineItemDraft = new LineItemDraft
             {
                 Quantity  = quantity,
                 ProductId = product.Id,
                 Custom    = customFieldsDraft
             };
             var shoppingListDraft       = new ShoppingListDraft();
             shoppingListDraft.LineItems = new List <LineItemDraft> {
                 lineItemDraft
             };
             await WithUpdateableAsync(client, shoppingListDraft, DefaultShoppingListDraft, func);
         });
     });
 }
        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);
        }
Ejemplo n.º 4
0
        public static InventoryEntryDraft DefaultInventoryEntryDraftWithCustomType(InventoryEntryDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var inventoryEntryDraft = DefaultInventoryEntryDraft(draft);

            inventoryEntryDraft.Custom = customFieldsDraft;

            return(inventoryEntryDraft);
        }
        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 PaymentDraft DefaultPaymentDraftWithCustomType(PaymentDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var paymentDraft = DefaultPaymentDraft(draft);

            paymentDraft.Custom = customFieldsDraft;

            return(paymentDraft);
        }
        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);
        }
Ejemplo n.º 8
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);
        }
        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);
        }
Ejemplo n.º 10
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 CategoryDraft DefaultCategoryDraftWithAssetWithCustomType(CategoryDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };
            var categoryDraft = DefaultCategoryDraft(draft);
            var assetDraft    = TestingUtility.GetAssetDraft();

            assetDraft.Custom    = customFieldsDraft;
            categoryDraft.Assets = new List <AssetDraft> {
                assetDraft
            };
            return(categoryDraft);
        }
        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);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        public void SerializeCustomField()
        {
            ISerializerService serializerService = this.serializationFixture.SerializerService;
            var customFieldsDraft = new CustomFieldsDraft()
            {
                Fields = new Fields()
                {
                    { "foo", "bar" },
                    { "Fooz", "Bars" },
                    { "Bar", new EnumValue {
                          Key = "BarKey", Label = "BarLabel"
                      } }
                }
            };
            string result1 = serializerService.Serialize(customFieldsDraft);

            JToken resultFormatted     = JValue.Parse(result1);
            string serialized          = File.ReadAllText("Resources/CustomFields/CustomFieldsDraft.json");
            JToken serializedFormatted = JValue.Parse(serialized);

            serializedFormatted.Should().BeEquivalentTo(resultFormatted);

            var draft = new Fields()
            {
                { "foo", "bar" },
                { "Fooz", "Bars" },
                { "Bar", new EnumValue {
                      Key = "BarKey", Label = "BarLabel"
                  } }
            };

            string result2 = serializerService.Serialize(draft);

            resultFormatted     = JValue.Parse(result2);
            serialized          = File.ReadAllText("Resources/CustomFields/Fields.json");
            serializedFormatted = JValue.Parse(serialized);
            serializedFormatted.Should().BeEquivalentTo(resultFormatted);
        }