public void Create_Does_Not_Save__Restaurant_When_Invalid() { var db = new FakeOdeToFoodDb(); var controller = new RestaurantController(db); controller.ModelState.AddModelError("", "Invalid"); controller.Create(new Restaurant()); Assert.AreEqual(0, db.Added.Count); }
public void Create_Saves_Restaurant_When_Valid() { var db = new FakeOdeToFoodDb(); var controller = new RestaurantController(db); controller.Create(new Restaurant()); Assert.AreEqual(1, db.Added.Count); Assert.AreEqual(true, db.Saved); }
public void Create_Does_Not_Save_Restaurante_When_invalid() { var db = new FakeOdeToFoodDb(); var controller = new RestaurantController(db); controller.ModelState.AddModelError("", "Invalid"); controller.Create(new Restaurant()); Assert.AreEqual(0, db.Added.Count); }
public void Index() { // Arrange var db = new FakeOdeToFoodDb(); db.AddSet(TestData.Restaurants); HomeController controller = new HomeController(db); controller.ControllerContext = new FakeControllerContext(); // Act ViewResult result = controller.Index() as ViewResult; IEnumerable<RestaurantListViewModel> model = result.Model as IEnumerable<RestaurantListViewModel>; // Assert Assert.AreEqual(10, model.Count()); }
public void Index() { // Arrange var db = new FakeOdeToFoodDb(); db.AddSet(TestData.Restaurants); HomeController controller = new HomeController(db); controller.ControllerContext = new FakeControllerContext(); // Act ViewResult result = controller.Index() as ViewResult; IEnumerable <RestaurantListViewModel> model = result.Model as IEnumerable <RestaurantListViewModel>; // Assert we get 10 restaurants in the list Assert.AreEqual(10, model.Count()); }