public void PathRoute() { var url = new Uri("http://163.com/News/Test/1"); { var pathSegments = PathSegments.Create(url.AbsolutePath); var template = new RewritePathTemplate("/{path*}"); var values = template.GetRouteValues(pathSegments); Assert.AreEqual(values.Count, 1); Assert.AreEqual(values.Keys.First(), "path"); Assert.AreEqual(values.Values.First(), "News/Test/1"); Assert.AreEqual(values["path"], "News/Test/1"); } { var template = new RewriteRequestTemplate("http://163.com/news/{path*}"); var values = template.GetRouteValues(new RouteRequestData(new HttpRequestMessage(HttpMethod.Get, url))); Assert.AreEqual(values.Count, 1); Assert.AreEqual(values.Keys.First(), "path"); Assert.AreEqual(values.Values.First(), "Test/1"); Assert.AreEqual(values["path"], "Test/1"); } }
public void EmptyPath() { var pathTemplate = new RewritePathTemplate("/{path*}"); var values = pathTemplate.GetRouteValues(PathSegments.Create("/")); Assert.IsTrue(values.ContainsKey("path")); Assert.AreEqual(values["path"], null); }
public void PathSegmentsTest() { var segments = PathSegments.Create("/a/b/c"); Assert.AreEqual(segments.Count, 3); Assert.AreEqual(segments[0], "a"); Assert.AreEqual(segments[1], "b"); Assert.AreEqual(segments[2], "c"); }
public void Path() { var result = PathSegments.Create("/favicon.ico"); }