public async Task CategoryDoesntExistTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); dbContext.Categories.Add(new Category { Name = "Fist", }); await dbContext.SaveChangesAsync(); var repository = new EfDeletableEntityRepository <Category>(dbContext); var service = new CategoriesService(repository); Assert.False(service.CategoryExist("Test1")); }
public async Task CreateCategoryTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Category>(dbContext); var service = new CategoriesService(repository); var category = new CreateCategoryViewModel { Description = "Test", ImageUrl = "Test", Name = "Test", }; await service.CreateCategoryAsync(category); Assert.True(service.CategoryExist("Test")); }