public async Task TestIfCategoryExistsReturnsFalse() { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var productService = new ProductServices(context); Assert.False(await productService.CategoryExistsAsync("NonExisting")); }
public async Task TestIfCategoryExistsThrowsException() { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var productService = new ProductServices(context); await Assert.ThrowsAsync <InvalidOperationException>(async() => { await productService.CategoryExistsAsync(null); }); }
public async Task TestIfCategoryExistsReturnsTrue(string category) { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var productService = new ProductServices(context); await context.Categories.AddAsync(new Category { Name = category }); await context.SaveChangesAsync(); Assert.True(await productService.CategoryExistsAsync(category)); }