public async Task TesIfGetIndexCategoryThrowsError(string category) { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var adminPageService = new Areas.Administration.Services.AdminIndexPageServices(context); await Assert.ThrowsAsync <NullReferenceException>(async() => { await adminPageService.GetIndexCategoryAsync(category); }); }
public async Task TestIfGetIndexCategoryReturnsCorrectResult(string pagename, string categoryName) { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var adminPageService = new Areas.Administration.Services.AdminIndexPageServices(context); await adminPageService.CreateIndexPageAsync(pagename); var form = new CreatePageCategoryViewModel(); form.AllHref = "AllHref"; form.AllName = "AllLaptops"; form.CategoryName = categoryName; await adminPageService.AddIndexPageCategoryAsync(form, "pictureUrl", "PictureName"); var result = await adminPageService.GetIndexCategoryAsync(categoryName); Assert.NotEmpty(result); Assert.Contains(result, (pc) => pc.CategoryName == categoryName); }