public void TestIndexWithNoLogin() { //Arrange var dbContext = new RestaurantContext(); var menuManager = new MenuManager(dbContext); var menusController = new MenusController(menuManager); //Act and Assert Assert.ThrowsException <ArgumentNullException>(() => menusController.Index()); }
public void Index() { // Arrange MenusController controller = new MenusController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.AreEqual("Menu", result.ViewBag.Message); }
public void TestIndexWithLogin() { //Arrange var dbContext = new RestaurantContext(); var menuManager = new MenuManager(dbContext); var menusController = new MenusController(menuManager); menusController.UserID = "8774f57e-f0c7-450a-b17e-09e30668eddc"; //Act var result = menusController.Index() as ViewResult; var menus = (IEnumerable <Menu>)result.ViewData.Model; var count = 0; foreach (var item in menus) { count++; } //Assert Assert.AreEqual <int>(2, count); }
public void Index_ReturnsCorrectView_True() { Assert.IsInstanceOfType(_controller.Index(), typeof(ViewResult)); }