예제 #1
0
        private void SetupWizardController(bool useCurrentRouteForRedirects)
        {
            helper.WizardController = repository.DynamicMock <IWizardController>();
            SetupResult.For(helper.WizardController.UseCurrentRouteForRedirects).Return(useCurrentRouteForRedirects);
            repository.Replay(helper.WizardController);

            if (useCurrentRouteForRedirects)
            {
                repository.BackToRecord(controllerContext, BackToRecordOptions.None);
                var routeMatch = new RouteMatch();
                routeMatch.AddNamed("manufacturer", "Ford");
                routeMatch.AddNamed("model", "Falcon");
                SetupResult.For(controllerContext.RouteMatch).Return(routeMatch);
                SetupResult.For(controllerContext.AreaName).Return("Cars");
                repository.Replay(controllerContext);

                var routingEngine = new RoutingEngine();
                routingEngine.Add(
                    new PatternRoute("/<area>/<manufacturer>/AddOptionsWizard/<model>/[action]")
                    .DefaultForController().Is("AddOptionsWizardController")
                    .DefaultForAction().Is("start"));
                helper.UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), routingEngine);
                helper.CurrentUrl = new UrlInfo("Cars", "CarsController", "View", String.Empty, "rails");
                helper.UrlBuilder.UseExtensions = false;
            }
        }
예제 #2
0
        public void RedirectUsingRoute_InheritingParameters()
        {
            engine.Add(new PatternRoute("/something/<param1>/admin/[controller]/[action]/[id]"));

            var match = new RouteMatch();

            match.AddNamed("param1", "Homer");

            var url      = new UrlInfo("area", "home", "index", "", ".castle");
            var response = new StubResponse(url, urlBuilder, urlBuilder.ServerUtil, match);

            response.RedirectUsingRoute("cart", "checkout", true);
            Assert.AreEqual("/something/Homer/admin/cart/checkout", response.RedirectedTo);
        }
		private void SetupWizardController(bool useCurrentRouteForRedirects)
		{
			helper.WizardController = repository.DynamicMock<IWizardController>();
			SetupResult.For(helper.WizardController.UseCurrentRouteForRedirects).Return(useCurrentRouteForRedirects);
			repository.Replay(helper.WizardController);

			if (useCurrentRouteForRedirects)
			{
				repository.BackToRecord(controllerContext, BackToRecordOptions.None);
				var routeMatch = new RouteMatch();
				routeMatch.AddNamed("manufacturer", "Ford");
				routeMatch.AddNamed("model", "Falcon");
				SetupResult.For(controllerContext.RouteMatch).Return(routeMatch);
				SetupResult.For(controllerContext.AreaName).Return("Cars");
				repository.Replay(controllerContext);

				var routingEngine = new RoutingEngine();
				routingEngine.Add(
					new PatternRoute("/<area>/<manufacturer>/AddOptionsWizard/<model>/[action]")
						.DefaultForController().Is("AddOptionsWizardController")
						.DefaultForAction().Is("start"));
				helper.UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), routingEngine);
				helper.CurrentUrl = new UrlInfo("Cars", "CarsController", "View", String.Empty, "rails");
				helper.UrlBuilder.UseExtensions = false;
			}
		}