public async Task TestIfAdditemsToCategoryThrowsError()
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var adminPageService = new Areas.Administration.Services.AdminIndexPageServices(context);

            var form = new IndexItemsCategoryViewModel();


            await Assert.ThrowsAsync <NullReferenceException>(async() =>
            {
                await adminPageService.AdditemsToCategoryAsync(form);
            });
        }
        public async Task TestIfAdditemsToCategoryWorksAccordingly(string text, string href)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var adminPageService = new Areas.Administration.Services.AdminIndexPageServices(context);

            await adminPageService.CreateIndexPageAsync("Index");


            var formCategory = new CreatePageCategoryViewModel();

            formCategory.AllHref      = "AllHref";
            formCategory.AllName      = "AllLaptops";
            formCategory.CategoryName = "Category";

            await adminPageService.AddIndexPageCategoryAsync(formCategory, "pictureUrl", "PictureName");

            var form = new IndexItemsCategoryViewModel();

            form.PageCategory = "Category";

            form.ItemCategory = "Price";

            form.Items = new List <IndexPageItemsViewModel>();

            form.Items.Add(new IndexPageItemsViewModel
            {
                Text = text,
                Href = href,
            });

            await adminPageService.AdditemsToCategoryAsync(form);

            var result = await context.PageCategories.FirstOrDefaultAsync(x => x.CategoryName == "Category");

            Assert.Contains(result.ItemsCategories, (ic) => ic.Category == "Price");
            Assert.Contains(result.ItemsCategories, (ic) => EnumerableExtensions.Any(ic.Items));



            foreach (var ic in result.ItemsCategories)
            {
                foreach (var item in ic.Items)
                {
                    Assert.Equal(text, item.Text);
                    Assert.Equal(href, item.Href);
                }
            }
        }
        public async Task TestIfEditIndexPageCategoryWorksAccordingly(string text, string href)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var adminPageService = new Areas.Administration.Services.AdminIndexPageServices(context);

            await adminPageService.CreateIndexPageAsync("Index");


            var formCategory = new CreatePageCategoryViewModel();

            formCategory.AllHref      = "AllHref";
            formCategory.AllName      = "AllLaptops";
            formCategory.CategoryName = "Category";

            await adminPageService.AddIndexPageCategoryAsync(formCategory, "pictureUrl", "PictureName");

            var form = new IndexItemsCategoryViewModel();

            form.PageCategory = "Category";

            form.ItemCategory = "Price";

            form.Items = new List <IndexPageItemsViewModel>();

            form.Items.Add(new IndexPageItemsViewModel
            {
                Text = text,
                Href = href,
            });

            await adminPageService.AdditemsToCategoryAsync(form);

            var model = new EditIndexCategoryViewModel();

            model.Category     = "Category";
            model.PageCategory = new List <EditCategoryViewModel>();

            var itemCategories = new List <EditItemCategoriesViewModel>();
            var items          = new List <IndexPageItemsViewModel>();

            items.Add(new IndexPageItemsViewModel
            {
                Text = "TextRand",
                Href = "HrefRand",
            });
            itemCategories.Add(new EditItemCategoriesViewModel
            {
                ItemCategory = "Price",
                Items        = items
            });
            model.PageCategory.Add(new EditCategoryViewModel
            {
                CategoryName   = "NewCategory",
                AllHref        = "NewAllHref",
                AllName        = "AllName",
                ItemCategories = itemCategories
            });


            await adminPageService.EditIndexPageCategoryAsync(model, "Category");

            var result = await context.Pages.FirstOrDefaultAsync(x => x.PageName == "Index");

            Assert.NotNull(result);

            Assert.Contains(result.Categories, (pc) => pc.CategoryName == "NewCategory");
            Assert.Contains(result.Categories, (pc) => pc.AllHref == "NewAllHref");
            Assert.Contains(result.Categories, (pc) => pc.AllName == "AllName");
        }