public static CategoryDraft DefaultCategoryDraftWithAsset(CategoryDraft draft)
        {
            var categoryDraft = DefaultCategoryDraft(draft);
            var assetDraft    = TestingUtility.GetAssetDraft();

            categoryDraft.Assets = new List <AssetDraft> {
                assetDraft
            };
            return(categoryDraft);
        }
        public static CategoryDraft DefaultCategoryDraftWithMultipleAssets(CategoryDraft draft, int assetsCount = 3)
        {
            var categoryDraft = DefaultCategoryDraft(draft);

            categoryDraft.Assets = new List <AssetDraft>();
            for (int i = 1; i <= assetsCount; i++)
            {
                var assetDraft = TestingUtility.GetAssetDraft();
                categoryDraft.Assets.Add(assetDraft);
            }
            return(categoryDraft);
        }
        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);
        }
Esempio n. 4
0
        public async Task UpdateCategoryAddAsset()
        {
            await WithUpdateableCategory(client, async category =>
            {
                Assert.Empty(category.Assets);
                var assetDraft = TestingUtility.GetAssetDraft();
                var action     = new AddAssetUpdateAction
                {
                    Asset = assetDraft
                };

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

                Assert.Single(updatedCategory.Assets);
                Assert.Equal(assetDraft.Key, updatedCategory.Assets[0].Key);
                return(updatedCategory);
            });
        }