public void ContrololerAddTest() { CodeBaseContext repo = new FakeCodeBaseContext(); CategoriesController controller = new CategoriesController { context = repo }; controller.Create(new Category { Title = "C#" , CategoryId=1, Articles=null}); repo.SaveChanges(); Assert.AreEqual("C#", repo.Categories.First().Title); }
public void ComtrollerEditCategory() { CodeBaseContext repo = new FakeCodeBaseContext(); repo.Categories.Add(new Category { Title = "C#", CategoryId = 1, Articles = null }); repo.SaveChanges(); var category = repo.Categories.First(); category.Title = "C++"; CategoriesController controller = new CategoriesController { context = repo }; controller.Edit(category); Assert.AreEqual("C++", repo.Categories.First().Title); }