public async Task EditCategory() { // Arrange var db = this.GetDatabase(); var category = new Category { Id = 1, Name = "test", PictureUrl = "https://test" }; db.Add(category); await db.SaveChangesAsync(); var adminCategoryService = new AdminCategoryService(db); // Act await adminCategoryService.EditAsync(1, "changed", "https://changed"); await db.SaveChangesAsync(); var result = adminCategoryService.ById(1); // Assert result .Name .Should() .Equals("changed"); }
public async Task CategoryById() { // 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 = adminCategoryService.ById(3); // Assert result .Name .Should() .Equals("Third"); }
public async Task ByIdShouldReturnTheItemThatIsCalled() { // Arrange //Mapper.Initialize(config => config.AddProfile<AutoMapperProfile>()); var db = this.Context; this.PopulateData(db); var categoriesService = new AdminCategoryService(db); var categoryId = 1; // Act var result = await categoriesService.ById(categoryId); // Assert result .Should() .NotBe(null); result .Name .Should() .Be("firstOne"); }