public Category Add(Category category) { this.categories.Add(category); this.categories.SaveChanges(); return category; }
public Category Update(int id, Category category) { var categoryToUpdate = this.categories.GetById(id); categoryToUpdate.Name = category.Name; this.categories.SaveChanges(); return categoryToUpdate; }
public void CategoriesControllerEditActionShouldRenderProperView() { var categoriesServicesMock = new Mock<ICategoriesServices>(); var newCategory = new Category { Name = "Delete me" }; categoriesServicesMock.Setup(x => x.Update(It.IsAny<int>(), newCategory)) .Returns(newCategory); var controller = new CategoriesController(categoriesServicesMock.Object); controller.WithCallTo(x => x.Edit(123)) .ShouldRenderView("Edit"); }