示例#1
0
        protected RedirectToRouteResult RedirectToNotFound(BaseController controller)
        {
            RedirectToRouteResult result = new RedirectToRouteResult(new RouteValueDictionary());
            controller.When(sub => sub.RedirectToNotFound()).DoNotCallBase();
            controller.RedirectToNotFound().Returns(result);

            return result;
        }
示例#2
0
        protected RedirectToRouteResult NotEmptyView(BaseController controller, Object model)
        {
            RedirectToRouteResult result = new RedirectToRouteResult(new RouteValueDictionary());
            controller.When(sub => sub.NotEmptyView(model)).DoNotCallBase();
            controller.NotEmptyView(model).Returns(result);

            return result;
        }
示例#3
0
        protected RedirectToRouteResult RedirectIfAuthorized(BaseController controller, String actionName, String controllerName)
        {
            RedirectToRouteResult result = new RedirectToRouteResult(new RouteValueDictionary());
            controller.When(sub => sub.RedirectIfAuthorized(actionName, controllerName)).DoNotCallBase();
            controller.RedirectIfAuthorized(actionName, controllerName).Returns(result);

            return result;
        }
示例#4
0
 /// <summary>
 /// Returns a ViewResult with content type set as xml
 /// </summary>
 public static ActionResult XmlViewResult(BaseController controller, object model, string viewName = null)
 {
     controller.ControllerContext.HttpContext.Response.ContentType = "text/xml; charset=UTF-8";
     if (model != null)
     {
         controller.ViewData.Model = model;
     }
     ViewResult result = new ViewResult();
     result.ViewName = viewName;
     result.ViewData = controller.ViewData;
     result.TempData = controller.TempData;
     return result;
 }
示例#5
0
        /// <summary>
        /// Returns a status 404 to the client and the error 404 view.
        /// </summary>
        /// <param name="emptyBody">true: the response ends</param>
        public static ActionResult NotFoundResult(BaseController controller, bool emptyBody)
        {
            controller.ControllerContext.HttpContext.Response.StatusCode = 404;
            if (emptyBody)
            {
                controller.ControllerContext.HttpContext.Response.End();
            }

            ViewResult viewResult = new ViewResult();
            viewResult.ViewName = "Errors/404";
            viewResult.MasterName = controller.GetDefaultMasterName();
            return viewResult;
        }
示例#6
0
 protected void ReturnCurrentAccountId(BaseController controller, String id)
 {
     controller.When(sub => { String get = sub.CurrentAccountId; }).DoNotCallBase();
     controller.CurrentAccountId.Returns(id);
 }
示例#7
0
 /// <summary>
 /// Returns a status 404 to the client and the error 404 view.
 /// </summary>
 /// <param name="controller"></param>
 /// <returns></returns>
 public static ActionResult NotFoundResult(BaseController controller)
 {
     return NotFoundResult(controller, false);
 }
示例#8
0
 public static ActionResult MovedPermanentlyResult(BaseController controller, object routeValues)
 {
     return new NearForums.Web.Extensions.MovedPermanentlyResult(routeValues);
 }
示例#9
0
 /// <summary>
 /// Returns a http status 403 to the client and the error 403 view.
 /// </summary>
 /// <param name="controller"></param>
 /// <returns></returns>
 public static ActionResult ForbiddenResult(BaseController controller)
 {
     return ForbiddenResult(controller, false);
 }