Esempio n. 1
0
        protected RedirectToActionResult RedirectToAction(AController controller, String action)
        {
            RedirectToActionResult result = new(null, null, null);

            controller.RedirectToAction(action).Returns(result);

            return(result);
        }
Esempio n. 2
0
        protected RedirectToActionResult RedirectToAction(AController baseController, String action, String controller)
        {
            RedirectToActionResult result = new(null, null, null);

            baseController.RedirectToAction(action, controller).Returns(result);

            return(result);
        }
Esempio n. 3
0
        protected RedirectToActionResult RedirectToDefault(AController controller)
        {
            RedirectToActionResult result = new(null, null, null);

            controller.RedirectToDefault().Returns(result);

            return(result);
        }
Esempio n. 4
0
        public void OnActionExecuting_SetsAuthorization()
        {
            controller = Substitute.ForPartsOf <AController>();
            controller.ControllerContext.HttpContext = Substitute.For <HttpContext>();
            controller.HttpContext.RequestServices.GetService(typeof(IAuthorization)).Returns(Substitute.For <IAuthorization>());

            controller.OnActionExecuting(context);

            Object expected = controller.HttpContext.RequestServices.GetRequiredService <IAuthorization>();
            Object actual   = controller.Authorization;

            Assert.Same(expected, actual);
        }
Esempio n. 5
0
        public AControllerTests()
        {
            controller = Substitute.ForPartsOf <AController>();

            controller.Url = Substitute.For <IUrlHelper>();
            controller.ControllerContext.RouteData = new RouteData();
            controller.TempData = Substitute.For <ITempDataDictionary>();
            controller.Authorization.Returns(Substitute.For <IAuthorization>());
            controller.ControllerContext.HttpContext = Substitute.For <HttpContext>();
            controller.HttpContext.RequestServices.GetService(typeof(IAuthorization)).Returns(Substitute.For <IAuthorization>());

            areaName       = controller.RouteData.Values["area"] as String;
            controllerName = (String)controller.RouteData.Values["controller"] !;
            action         = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
            context        = new ActionExecutingContext(action, new List <IFilterMetadata>(), new Dictionary <String, Object>(), controller);
        }
Esempio n. 6
0
        protected ViewResult NotEmptyView(AController controller, Object model)
        {
            controller.NotEmptyView(model).Returns(new ViewResult());

            return(controller.NotEmptyView(model));
        }
Esempio n. 7
0
        protected ViewResult NotFoundView(AController controller)
        {
            controller.NotFoundView().Returns(new ViewResult());

            return(controller.NotFoundView());
        }