public void MenusControllerDetailActionReturnsView() { decimal id = 1; ActionResult result = menusController.Details(id).Result as ActionResult; Assert.NotNull(result); }
public void TestDetailsWithMenu() { //Arrange var dbContext = new RestaurantContext(); var menuManager = new MenuManager(dbContext); var menusController = new MenusController(menuManager); var menuID = 1; //Act var result = menusController.Details(menuID) as ViewResult; var viewModel = (MenuDetailsViewModel)result.ViewData.Model; var categories = viewModel.Categories; var categoriesSameMenu = categories.All(c => c.MenuID == menuID); var countCategory = categories.Count(); var menuItems = viewModel.MenuItems; var countMenuItems = menuItems.Count(); var itemsSameMenu = menuItems.All(i => i.MenuID == menuID); //Assert Assert.AreEqual <int>(1, countCategory); Assert.AreEqual <int>(1, countMenuItems); Assert.IsTrue(categoriesSameMenu); Assert.IsTrue(itemsSameMenu); }
public void TestDetailsWithNullMenuID() { //Arrange var dbContext = new RestaurantContext(); var menuManager = new MenuManager(dbContext); var menusController = new MenusController(menuManager); int?menuID = null; //Act var result = menusController.Details(menuID); //Assert Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public async Task Details_IdIsNull_ReturnNotFound() { var result = await controller.Details(null); Assert.That(result, Is.InstanceOf <NotFoundResult>()); }