public void Init()
        {
            this.payModel = new PaymentModel
            {
                Applicationid = RandomData.GetInteger(100, 1000),
                PayableAmount = RandomData.GetInteger(100, 1000),
                IsPaid = false
            };

            this.paymentLogic = new Mock<IVetumaPaymentLogic>();

            this.callBackVetumaPaymentModel = new VetumaPaymentModel();
            this.paymentLogic.Setup(o => o.MakePayment(It.IsAny<VetumaPaymentModel>())).Callback<VetumaPaymentModel>(o => { this.callBackVetumaPaymentModel = o; });

            // prepare
            var session = new HttpSessionMock();
            session["ReturnControllerAction"] = new ReturnControllerActionIdentifier
            {
                ControllerName = "TestableCtr",
                ActionName = null,
                EntityId = null,
                BookmarkTag = null
            };
            this.controllerContext = HttpMocks.GetControllerContextMock(HttpMocks.GetHttpContextMock(sessionMock: session)).Object;
            this.urlHelper = new Mock<UrlHelper>().Object;
        }
        public void Init()
        {
            this.userManager = new Mock<IAuthenticationManager>();
            this.uriModel = new VetumaUriModel();
            this.vetumaAuth = new Mock<IVetumaAuthenticationLogic>();
            this.vetumaAuth.Setup(o => o.Authenticate(It.IsAny<string>(), It.IsAny<VetumaUriModel>()))
                .Callback<string, VetumaUriModel>((st, o) => { this.uriModel = o; });

            // prepare
            var session = new HttpSessionMock();
            session["ReturnControllerAction"] = new ReturnControllerActionIdentifier
            {
                ControllerName = "TestableCtr",
                ActionName = null,
                EntityId = null,
                BookmarkTag = null
            };
            this.controllerContext = HttpMocks.GetControllerContextMock(HttpMocks.GetHttpContextMock(sessionMock: session)).Object;
            this.urlHelper = new Mock<UrlHelper>().Object;
        }
        public void BaseControllerRedirectBackNoParmsGoesToSessionControllerAction()
        {
            // prepare
            var session = new HttpSessionMock();
            session["ReturnControllerAction"] = new ReturnControllerActionIdentifier
            {
                ControllerName = "TestableCtr",
                ActionName = "TestAction",
                EntityId = null,
                BookmarkTag = null
            };
            var context = HttpMocks.GetControllerContextMock(HttpMocks.GetHttpContextMock(sessionMock: session)).Object;
            var contr = new UnprotectedBase { ControllerContext = context };

            // act
            var result = contr.RedirectBack();

            // assert
            result.As<RedirectToRouteResult>().RouteValues.Should().ContainKeys("controller", "action");
            result.As<RedirectToRouteResult>().RouteValues.Should().NotContainKey("id");
            result.As<RedirectToRouteResult>().RouteValues["controller"].Should().Be("TestableCtr");
            result.As<RedirectToRouteResult>().RouteValues["action"].Should().Be("TestAction");
        }
        public void BaseControllerRedirectBackWithParmTagStoresTag()
        {
            // prepare
            var session = new HttpSessionMock();
            session["ReturnControllerAction"] = new ReturnControllerActionIdentifier
            {
                ControllerName = "FallbackCtr",
                ActionName = "FallbackAction",
                EntityId = "abcdef123",
                BookmarkTag = "FallbackTag"
            };

            var contr = new UnprotectedBase();
            var context = HttpMocks.GetControllerContextMock(HttpMocks.GetHttpContextMock(sessionMock: session), controller: contr).Object;
            contr.ControllerContext = context;

            // act
            var result = contr.RedirectBack("DirectedCtrl", "DirectedAction", "505050", "DirectTag");

            // assert
            contr.TempData.Should().ContainKey("bookmarkTag");
            contr.TempData["bookmarkTag"].Should().Be("DirectTag");
        }
        public void BaseControllerRedirectBackWithParmsGoesToSpecifiedControllerIndex()
        {
            // prepare
            var session = new HttpSessionMock();
            session["ReturnControllerAction"] = new ReturnControllerActionIdentifier
            {
                ControllerName = "FallbackCtr",
                ActionName = "FallbackAction",
                EntityId = "abcdef123",
                BookmarkTag = "FallbackTag"
            };
            var context = HttpMocks.GetControllerContextMock(HttpMocks.GetHttpContextMock(sessionMock: session)).Object;
            var contr = new UnprotectedBase { ControllerContext = context };

            // act
            var result = contr.RedirectBack("DirectedCtrl");

            // assert
            result.As<RedirectToRouteResult>().RouteValues.Should().ContainKeys("controller", "action");
            result.As<RedirectToRouteResult>().RouteValues.Should().NotContainKey("id");
            result.As<RedirectToRouteResult>().RouteValues["controller"].Should().Be("DirectedCtrl");
            result.As<RedirectToRouteResult>().RouteValues["action"].Should().Be("Index");
        }
        public void PrepareController()
        {
            // prepare
            var session = new HttpSessionMock();
            session["ReturnControllerAction"] = new ReturnControllerActionIdentifier
            {
                ControllerName = "TestableCtr",
                ActionName = null,
                EntityId = null,
                BookmarkTag = null
            };
            session["callerURL"] = "https://localhost";
            this.controllerContext = HttpMocks.GetControllerContextMock(HttpMocks.GetHttpContextMock(sessionMock: session)).Object;

            this.localController = new LocalizationController() { ControllerContext = this.controllerContext };

            this.helpLogic = new Mock<IHelpSupportLogic>();
            this.helpLogic.Setup(o => o.CreateUpdateFAQ(It.IsAny<TranslateFAQPageModel>()));
            this.helpLogic.Setup(o => o.DeleteQuestion(It.IsAny<int>()));
            this.helpLogic.Setup(o => o.CreateNewfaq()).Returns(It.IsAny<int>());
            this.helpLogic.Setup(o => o.GetFAQResources(It.IsAny<int>(), It.IsAny<SupportedLanguage>())).Returns(It.IsAny<TranslateFAQPageModel>());
            this.localController.HelpLogic = this.helpLogic.Object;

            this.localManager = new Mock<ILocalizationManager>();
            // this.localController.LocalMgr = this.localManager.Object;

            this.localEditor = new Mock<ILocalizationEditor>();
            this.localEditor.Setup(o => o.SaveResources(It.IsAny<WebElementModel>()));
            this.localEditor.Setup(o => o.GetResource(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<SupportedLanguage>())).Returns(It.IsAny<WebElementModel>());
            this.localController.LocalEditor = this.localEditor.Object;
        }
        /// <summary>
        /// Stores the return route for "Cancel" and "Back" operations.
        /// This method must be called from Controller Actions and it will automatically
        /// store route to current path.
        /// You can convert it to Filter attribute if you are certain you need storing route even if
        /// it is not beneficial due to route restrictions (security, validations)
        /// </summary>
        /// <param name="bookmarkTag">Optional: The bookmark tag if you need additional page place handling (like preselecting/opening panel, selecting tab, scrolling to bookmark etc.).</param>
        protected void StoreReturnRoute(string bookmarkTag = null)
        {
            string controllerName = null;
            string actionName = null;
            string idValue = null;

            if (this.ControllerContext.RouteData.Values.ContainsKey("controller"))
            {
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            }

            if (this.ControllerContext.RouteData.Values.ContainsKey("action"))
            {
                actionName = this.ControllerContext.RouteData.Values["action"].ToString();
            }

            if (this.ControllerContext.RouteData.Values.ContainsKey("id"))
            {
                idValue = this.ControllerContext.RouteData.Values["id"].ToString();
            }

            var returnRoute = new ReturnControllerActionIdentifier { ControllerName = controllerName, ActionName = actionName, EntityId = idValue };
            if (!string.IsNullOrEmpty(bookmarkTag))
            {
                returnRoute.BookmarkTag = bookmarkTag;
            }

            this.ReturnControllerAction = returnRoute;
        }