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

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

            await Assert.ThrowsAsync <NullReferenceException>(async() =>
            {
                var model = new AddBoxViewModel();

                await adminPageService.AddBoxAsync(model);
            });
        }
        public async Task TestIfEditBoxesWorksAccordingly()
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

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

            var model = new AddBoxViewModel();

            await adminPageService.CreateIndexPageAsync("Index");

            model.Color = "Red";
            model.Href  = "TestModelHref";
            model.Text  = "TestModelText";

            await adminPageService.AddBoxAsync(model);

            var form = new EditBoxViewModel();

            form.BoxViewModel = new List <AddBoxViewModel>();

            form.BoxViewModel.Add(new AddBoxViewModel
            {
                Text      = "Tested",
                Color     = "Tested",
                Href      = "Tested",
                IsDeleted = true,
            });

            await adminPageService.EditBoxesAsync(form);

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

            var boxes = page.ColorfulBoxes.Where(x => x.IsDeleted == false).ToList();

            Assert.Empty(boxes);

            var deletedBoxes = page.ColorfulBoxes.Where(x => x.IsDeleted == true).ToList();

            foreach (var box in deletedBoxes)
            {
                Assert.Equal(box.Color, "Tested");
                Assert.Equal(box.Href, "Tested");
                Assert.Equal(box.Text, "Tested");
                Assert.True(box.IsDeleted);
            }
        }
        public async Task TestIfGetAllBoxesWorksAccordingly(string color, string href, string text)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

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

            var model = new AddBoxViewModel();

            await adminPageService.CreateIndexPageAsync("Index");

            model.Color = color;
            model.Href  = href;
            model.Text  = text;

            await adminPageService.AddBoxAsync(model);

            var result = await adminPageService.GetAllBoxesAsync();

            Assert.NotEmpty(result);
            Assert.Equal(1, result.Count());
        }
        public async Task TestIfAddBoxWorksAccordingly(string color, string href, string text)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

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

            var model = new AddBoxViewModel();

            await adminPageService.CreateIndexPageAsync("Index");

            model.Color = color;
            model.Href  = href;
            model.Text  = text;

            await adminPageService.AddBoxAsync(model);

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

            Assert.NotEmpty(result.ColorfulBoxes);

            Assert.Contains(result.ColorfulBoxes, (cb) => cb.Text == text && cb.Href == href && cb.Color == color);
        }