public void Index_AskForDefaultPage_GetViewResult() { var auth = DependencyResolver.Current.GetService <IAuthentication>(); var controller = DependencyResolver.Current.GetService <webTemplate.Web.Areas.Admin.Controllers.UserController>(); auth.Login("admin"); var route = new RouteData(); route.Values.Add("controller", "User"); route.Values.Add("action", "Index"); route.Values.Add("area", "Admin"); var values = new FakeValueProvider(); values["page"] = 2; var httpContext = new MockHttpContext(auth).Object; ControllerContext context = new ControllerContext(new RequestContext(httpContext, route), controller); controller.ControllerContext = context; var controllerActionInvoker = new FakeControllerActionInvoker <ViewResult>(values); var result = controllerActionInvoker.InvokeAction(controller.ControllerContext, "Index"); }
public void Index_AskForDefaultPage_GetViewResult() { var controller = DependencyResolver.Current.GetService<webTemplate.Areas.Default.Controllers.HomeController>(); var route = new RouteData(); route.Values.Add("controller", "Home"); route.Values.Add("action", "Index"); route.Values.Add("area", "Default"); var httpContext = new MockHttpContext().Object; ControllerContext context = new ControllerContext(new RequestContext(httpContext, route), controller); controller.ControllerContext = context; var controllerActionInvoker = new FakeControllerActionInvoker<ViewResult>(); var result = controllerActionInvoker.InvokeAction(controller.ControllerContext, "Index"); }
public void Index_NotAuthorizeGetDefaultView_RedirectToLoginPage() { var auth = DependencyResolver.Current.GetService<IAuthentication>(); auth.LogOut(); var httpContext = new MockHttpContext(auth).Object; var controller = DependencyResolver.Current.GetService<Areas.Admin.Controllers.HomeController>(); var route = new RouteData(); route.Values.Add("controller", "Home"); route.Values.Add("action", "Index"); route.Values.Add("area", "Admin"); ControllerContext context = new ControllerContext(new RequestContext(httpContext, route), controller); controller.ControllerContext = context; var controllerActionInvoker = new FakeControllerActionInvoker<HttpUnauthorizedResult>(); var result = controllerActionInvoker.InvokeAction(controller.ControllerContext, "Index"); }
public void Index_AdminAuthorize_GetViewResult() { var auth = DependencyResolver.Current.GetService<IAuthentication>(); auth.Login("admin", "password", false); var httpContext = new MockHttpContext(auth).Object; var controller = DependencyResolver.Current.GetService<Areas.Admin.Controllers.HomeController>(); var route = new RouteData(); route.Values.Add("controller", "Home"); route.Values.Add("action", "Index"); route.Values.Add("area", "Admin"); ControllerContext context = new ControllerContext(new RequestContext(httpContext, route), controller); controller.ControllerContext = context; var controllerActionInvoker = new FakeControllerActionInvoker<ViewResult>(); var result = controllerActionInvoker.InvokeAction(controller.ControllerContext, "Index"); }
public void Index_AskForDefaultPage_GetViewResult() { var controller = DependencyResolver.Current.GetService <webTemplate.Web.Areas.Default.Controllers.HomeController>(); var route = new RouteData(); route.Values.Add("controller", "Home"); route.Values.Add("action", "Index"); route.Values.Add("area", "Default"); var httpContext = new MockHttpContext().Object; ControllerContext context = new ControllerContext(new RequestContext(httpContext, route), controller); controller.ControllerContext = context; var controllerActionInvoker = new FakeControllerActionInvoker <ViewResult>(); var result = controllerActionInvoker.InvokeAction(controller.ControllerContext, "Index"); }
public void Index_NotAuthorizeGetDefaultView_RedirectToLoginPage() { var auth = DependencyResolver.Current.GetService <IAuthentication>(); auth.LogOut(); var httpContext = new MockHttpContext(auth).Object; var controller = DependencyResolver.Current.GetService <Web.Areas.Admin.Controllers.HomeController>(); var route = new RouteData(); route.Values.Add("controller", "Home"); route.Values.Add("action", "Index"); route.Values.Add("area", "Admin"); ControllerContext context = new ControllerContext(new RequestContext(httpContext, route), controller); controller.ControllerContext = context; var controllerActionInvoker = new FakeControllerActionInvoker <HttpUnauthorizedResult>(); var result = controllerActionInvoker.InvokeAction(controller.ControllerContext, "Index"); }
public void Index_AskForDefaultPage_GetViewResult() { var auth = DependencyResolver.Current.GetService<IAuthentication>(); var controller = DependencyResolver.Current.GetService<webTemplate.Areas.Admin.Controllers.UserController>(); auth.Login("admin"); var route = new RouteData(); route.Values.Add("controller", "User"); route.Values.Add("action", "Index"); route.Values.Add("area", "Admin"); var values = new FakeValueProvider(); values["page"] = 2; var httpContext = new MockHttpContext(auth).Object; ControllerContext context = new ControllerContext(new RequestContext(httpContext, route), controller); controller.ControllerContext = context; var controllerActionInvoker = new FakeControllerActionInvoker<ViewResult>(values); var result = controllerActionInvoker.InvokeAction(controller.ControllerContext, "Index"); }