public void AdminEditItem() { MockContext mockContext = new MockContext(); mockContext.Cookies.Add(new HttpCookie("UserSettings", "Role=SystemAdmin")); var homeController = new HomeController() { ControllerContext = new ControllerContext() { HttpContext = mockContext.Http.Object } }; //act var result = homeController.EditItem(1) as ViewResult; Assert.AreEqual("EditItem", result.ViewName); }
public void AdminEditNotExistingItem() { MockContext mockContext = new MockContext(); mockContext.Cookies.Add(new HttpCookie("UserSettings", "Role=SystemAdmin")); var homeController = new HomeController() { ControllerContext = new ControllerContext() { HttpContext = mockContext.Http.Object } }; //act var result = homeController.EditItem(0) as RedirectToRouteResult; Assert.AreEqual("Index", result.RouteValues["Action"]); }
public void CustomerEditItemDetails() { MockContext mockContext = new MockContext(); Item myItem = new Item(); RestaurantDatabaseEntities db = new RestaurantDatabaseEntities(); myItem = db.Items.Find(1); mockContext.Cookies.Add(new HttpCookie("UserSettings", "Role=Customer")); var homeController = new HomeController() { ControllerContext = new ControllerContext() { HttpContext = mockContext.Http.Object } }; //act var result = homeController.EditItem(myItem) as RedirectToRouteResult; Assert.AreEqual("Index", result.RouteValues["Action"]); }