public async Task ShowingAllCategories() { // Arrange var db = this.GetDatabase(); var firstCategory = new Category { Id = 1, Name = "First" }; var secondCategory = new Category { Id = 2, Name = "Second" }; var thirdCategory = new Category { Id = 3, Name = "Third" }; db.AddRange(firstCategory, secondCategory, thirdCategory); await db.SaveChangesAsync(); var adminCategoryService = new AdminCategoryService(db); // Act var result = await adminCategoryService.AllAsync(); // Assert result .Should() .HaveCount(3); }
public async Task DeleteCategory() { // Arrange var db = this.GetDatabase(); var firstCategory = new Category { Id = 1, Name = "test1" }; var secondCategory = new Category { Id = 2, Name = "test2" }; var thirdCategory = new Category { Id = 3, Name = "test3" }; db.AddRange(firstCategory, secondCategory, thirdCategory); await db.SaveChangesAsync(); var adminCategoryService = new AdminCategoryService(db); // Act await adminCategoryService.Delete(1); await db.SaveChangesAsync(); var result = await adminCategoryService.AllAsync(); // Assert result .Should() .HaveCount(2); }
public async Task CreatingCategories() { // Arrange var db = this.GetDatabase(); var adminCategoryService = new AdminCategoryService(db); // Act await adminCategoryService.CreateAsync("test", "https://test"); var result = await adminCategoryService.AllAsync(); // Assert result .Should() .HaveCount(1); }
public async Task AllAsyncShouldReturnCollectionOfAllItems() { // Arrange //Mapper.Initialize(config => config.AddProfile<AutoMapperProfile>()); var db = this.Context; this.PopulateData(db); var categoriesService = new AdminCategoryService(db); // Act var result = await categoriesService.AllAsync(); // Assert result .Should() .Match(r => r.ElementAt(0).Id == 1 && r.ElementAt(1).Id == 2 && r.ElementAt(2).Id == 3) .And .HaveCount(3); }