public void TestIndexNotNull() { Init("*****@*****.**"); PermissionsController controller = new PermissionsController(); CurrentUser.setCurrentUser("*****@*****.**", "Superusuario", "0000000001", "0000000001"); Assert.IsNotNull(controller.Index()); }
public void TestEntrarCargarUsuariosSinPermiso() { Init("*****@*****.**"); CurrentUser.setCurrentUser("*****@*****.**", "Estudiante", "0000000001", "0000000001"); PermissionsController controller = new PermissionsController(); RedirectToRouteResult result = controller.Index() as RedirectToRouteResult; System.Web.Routing.RouteValueDictionary dictionary = new System.Web.Routing.RouteValueDictionary(); dictionary.Add("action", "Index"); dictionary.Add("controller", "Home"); RedirectToRouteResult expected = new RedirectToRouteResult(dictionary); Assert.AreEqual(controller.TempData["alertmessage"], "No tiene permisos para acceder a esta página."); Assert.AreEqual(result.RouteValues["action"], expected.RouteValues["action"]); Assert.AreEqual(result.RouteValues["controller"], expected.RouteValues["controller"]); }
public void TestGuardarPermisosSinPermiso() { Init("*****@*****.**"); CurrentUser.setCurrentUser("*****@*****.**", "Estudiante", "0000000001", "0000000001"); var httpContext = new HttpContext( new HttpRequest("", "http://localhost:44334/Home/Login", ""), new HttpResponse(new StringWriter()) ); var tempData = new TempDataDictionary(); PermissionsController controller = new PermissionsController() { TempData = tempData }; PermissionsViewHolder model = new PermissionsViewHolder(); RedirectToRouteResult result = controller.Index(model) as RedirectToRouteResult; System.Web.Routing.RouteValueDictionary dictionary = new System.Web.Routing.RouteValueDictionary(); dictionary.Add("action", "../Home/Index"); RedirectToRouteResult expected = new RedirectToRouteResult(dictionary); Assert.AreEqual(controller.TempData["alertmessage"], "No tiene permisos para acceder a esta página."); Assert.AreEqual(result.RouteValues["action"], expected.RouteValues["action"]); }