public async Task TestIfGetAllBoxesForPageWorksAccordingly(string pageName, string href, string text, string color) { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var categoryPagesService = new Areas.Administration.Services.AdminCategoryPagesServices(context); await context.Pages.AddAsync(new Page { PageName = pageName, ColorfulBoxes = new List <ColorfulBox>(), }); await context.SaveChangesAsync(); var model = new AddBoxViewModel(); model.Color = color; model.Href = href; model.Text = text; model.PageName = pageName; await categoryPagesService.AddBoxAsync(model); var result = await categoryPagesService.GetAllBoxesForPageAsync(pageName); Assert.NotEmpty(result); Assert.Contains(result, x => x.Href == href && x.Text == text && x.Color == color); }
public async Task TestIfAddBoxThrowsError() { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var categoryPagesService = new Areas.Administration.Services.AdminCategoryPagesServices(context); await Assert.ThrowsAsync <NullReferenceException>(async() => { var model = new AddBoxViewModel(); await categoryPagesService.AddBoxAsync(model); }); }