public void CreateDoesNotSaveRestaurantWhenInvalid() { var db = new TestOdeToFoodDb(); var controller = new RestaurantController(db); controller.ModelState.AddModelError("", "Invalid"); controller.Create(new Restaurant()); Assert.AreEqual(0, db.Added.Count); }
public void CreateSavesRestaurantWhenValid() { var db = new TestOdeToFoodDb(); var controller = new RestaurantController(db); controller.Create(new Restaurant()); Assert.AreEqual(1, db.Added.Count); Assert.AreEqual(true, db.Saved); }
public void Index() { // Arrange var db = new TestOdeToFoodDb(); db.AddSet(TestData.Restaurants); HomeController controller = new HomeController(db); controller.ControllerContext = new TestControllerContext(); // Act ViewResult result = controller.Index() as ViewResult; IEnumerable <RestaurantListViewModel> model = result.Model as IEnumerable <RestaurantListViewModel>; // Assert //Assert.AreEqual("Modify this template to jump-start your ASP.NET MVC application.", result.ViewBag.Message); Assert.AreEqual(10, model.Count()); }