public void non_admin_category_list_producers() { //Arrange var controller = new CategoryController(new CategoryBLL(new CategoryDALStub())); //Act var result = (RedirectToRouteResult)controller.ListProducers(null, null, null, null, null); //Assert Assert.AreEqual("LogIn", result.RouteValues["Action"]); Assert.AreEqual("Main", result.RouteValues["Controller"]); }
public void category_list_producers() { //Arrange TestControllerBuilder builder = new TestControllerBuilder(); var controller = new CategoryController(new CategoryBLL(new CategoryDALStub())); builder.InitializeController(controller); builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true }; //Act var action = (ViewResult)controller.ListProducers(2, 2, null, null, null); var result = (PagedList<ProducerInfo>)action.Model; //Assert Assert.IsNotNull(result); Assert.AreEqual(2,result.PageNumber); Assert.IsInstanceOfType(result, typeof(IPagedList<ProducerInfo>)); Assert.IsTrue(result[0].prodId < result[1].prodId); }