public void ItShouldBePossibleToHandleUrlWithParameterSetValueOnly()
		{
			IRoutingHandler rs = new RoutingService();
			rs.LoadControllers(new[] { typeof(MockController) });
			rs.MapRoute("", "~/{controller}/Fuffa/{id}", new { Controller = "Mock", Action = "Index", Id = RoutingParameter.Optional });
			var ctx = CreateRequest("http://127.0.0.1/Mock/Fuffa");

			var result = rs.Resolve(ctx.Request.Url.LocalPath, ctx);
			Assert.IsNotNull(result);

			Assert.AreEqual(2, result.Parameters.Count);
			Assert.IsTrue(result.Parameters.ContainsKey("controller"));
			Assert.AreEqual("Mock", result.Parameters["controller"]);
			Assert.IsTrue(result.Parameters.ContainsKey("action"));
			Assert.AreEqual("Index", result.Parameters["action"]);
		}
示例#2
0
        public static void Resolve(ControllerActionRequest actionRequest, Action <ControllerContext> responseCallback)
        {
            Guard.ArgumentNotNull(actionRequest, "request");
            Guard.ArgumentNotNull(responseCallback, "responseCallback");

            // NOTE_: if the response is a action context response, we send that else we wrap it in a action
            // context response this is done because the api expects this..
            RoutingService.Resolve(actionRequest, (r) =>
            {
                if (typeof(ControllerContext).IsAssignableFrom(r.GetType()))
                {
                    responseCallback((ControllerContext)r);
                }
                else
                {
                    responseCallback(new ControllerContext(r));
                }
            });
        }
示例#3
0
        public static void Resolve(NavigationRequest navigationRequest, Action <NavigationResponse> responseCallback)
        {
            Guard.ArgumentNotNull(navigationRequest, "navigationRequest");
            Guard.ArgumentNotNull(responseCallback, "responseCallback");

            // NOTE_: if the response is a navigation response, we send that else we wrap it in a navigation response
            // this is done because the api expects this.. we need this though, because if an error occurs we will
            // get back UrlResponse not NavigationResponse.. so..
            RoutingService.Resolve(navigationRequest, (r) =>
            {
                if (typeof(NavigationResponse).IsAssignableFrom(r.GetType()))
                {
                    responseCallback((NavigationResponse)r);
                }
                else
                {
                    responseCallback(new NavigationResponse(r));
                }
            });
        }
		public void ItShouldBePossibleToDistinguishTwoDifferentRequest()
		{
			IRoutingHandler rs = new RoutingService();
			rs.LoadControllers(new[] { typeof(MockController) });
			rs.MapRoute("", "~/{controller}/Index/{id}", new { Controller = "Mock", Action = "MethodIndex", Id = RoutingParameter.Optional });
			rs.MapRoute("", "~/{controller}/Test/{id}", new { Controller = "Mock", Action = "MethodTest", Id = RoutingParameter.Optional });

			var ctx = CreateRequest("http://127.0.0.1/Mock/Index");
			var result = rs.Resolve(ctx.Request.Url.LocalPath, ctx);
			Assert.IsNotNull(result);

			Assert.AreEqual(2, result.Parameters.Count);
			Assert.IsTrue(result.Parameters.ContainsKey("controller"));
			Assert.AreEqual("Mock", result.Parameters["controller"]);
			Assert.IsTrue(result.Parameters.ContainsKey("action"));
			Assert.AreEqual("MethodIndex", result.Parameters["action"]);

			ctx = CreateRequest("http://127.0.0.1/Mock/Test");
			result = rs.Resolve(ctx.Request.Url.LocalPath, ctx);
			Assert.IsNotNull(result);

			Assert.AreEqual(2, result.Parameters.Count);
			Assert.IsTrue(result.Parameters.ContainsKey("controller"));
			Assert.AreEqual("Mock", result.Parameters["controller"]);
			Assert.IsTrue(result.Parameters.ContainsKey("action"));
			Assert.AreEqual("MethodTest", result.Parameters["action"]);
		}