示例#1
0
        public void MatchesUrlWhenTwoRegexesHaveSameNumberOfGroups()
        {
            var target      = new RoutingTable();
            var expectedFoo = typeof(int);
            var expectedBar = typeof(string);

            target.Add("/tests/{Id}/foo", expectedFoo);
            target.Add("/tests/{Id}/bar", expectedBar);
            IDictionary <string, string[]> variables;

            Assert.Equal(expectedFoo, target.Get("/tests/1/foo", out variables));
            Assert.Equal(expectedBar, target.Get("/tests/1/bar", out variables));
        }
 public void MatchesStaticUrl()
 {
     var target = new RoutingTable();
     var expected = typeof(RoutingTableTests);
     target.Add("/", expected);
     IDictionary<string, string> _;
     var actual = target.Get("/", out _);
     Assert.Equal(expected, actual);
 }
 public void MatchesDynamicUrlWithTrailingValues()
 {
     var target = new RoutingTable();
     var expected = typeof (RoutingTableTests);
     target.Add("/tests/{Id}/bar", expected);
     IDictionary<string, string[]> variables;
     var actual = target.Get("/tests/1/bar", out variables);
     Assert.Equal(expected, actual);
 }
 public void MatchesDynamicUrlWithOneVariable()
 {
     var target = new RoutingTable();
     var expected = typeof(RoutingTableTests);
     target.Add("/tests/{Id}", expected);
     IDictionary<string, string> variables;
     var actual = target.Get("/tests/1", out variables);
     Assert.Equal(expected, actual);
     Assert.Equal("1", variables["Id"]);
 }
 public void MatchesVanityUrlWithTrailingSlash()
 {
     var target = new RoutingTable();
     var expected = typeof(RoutingTableTests);
     target.Add("/{Name}", expected);
     IDictionary<string, string> variables;
     var actual = target.Get("/test/", out variables);
     Assert.Equal(expected, actual);
     Assert.Equal("test", variables["Name"]);
 }
 public void MatchesDynamicUrlWithTwoVariables()
 {
     var target = new RoutingTable();
     var expected = typeof(RoutingTableTests);
     target.Add("/tests/{Year}/{Month}", expected);
     IDictionary<string, string> variables;
     var actual = target.Get("/tests/2012/2", out variables);
     Assert.Equal(expected, actual);
     Assert.Equal("2012", variables["Year"]);
     Assert.Equal("2", variables["Month"]);
 }
示例#7
0
        public void MatchesStaticUrl()
        {
            var target   = new RoutingTable();
            var expected = typeof(RoutingTableTests);

            target.Add("/", expected);
            IDictionary <string, string[]> _;
            var actual = target.Get("/", out _);

            Assert.Equal(expected, actual);
        }
示例#8
0
        public void MatchesDynamicUrlWithTrailingValues()
        {
            var target   = new RoutingTable();
            var expected = typeof(RoutingTableTests);

            target.Add("/tests/{Id}/bar", expected);
            IDictionary <string, string[]> variables;
            var actual = target.Get("/tests/1/bar", out variables);

            Assert.Equal(expected, actual);
        }
示例#9
0
        public void MatchesDynamicUrlWithOneVariable()
        {
            var target   = new RoutingTable();
            var expected = typeof(RoutingTableTests);

            target.Add("/tests/{Id}", expected);
            IDictionary <string, string[]> variables;
            var actual = target.Get("/tests/1", out variables);

            Assert.Equal(expected, actual);
            Assert.Equal("1", variables["Id"][0]);
        }
示例#10
0
        public void MatchesVanityUrlWithTrailingSlash()
        {
            var target   = new RoutingTable();
            var expected = typeof(RoutingTableTests);

            target.Add("/{Name}", expected);
            IDictionary <string, string[]> variables;
            var actual = target.Get("/test/", out variables);

            Assert.Equal(expected, actual);
            Assert.Equal("test", variables["Name"][0]);
        }
示例#11
0
        public void MatchesDynamicUrlWithTwoVariables()
        {
            var target   = new RoutingTable();
            var expected = typeof(RoutingTableTests);

            target.Add("/tests/{Year}/{Month}", expected);
            IDictionary <string, string[]> variables;
            var actual = target.Get("/tests/2012/2", out variables);

            Assert.Equal(expected, actual);
            Assert.Equal("2012", variables["Year"][0]);
            Assert.Equal("2", variables["Month"][0]);
        }
 public void MatchesUrlWhenTwoRegexesHaveSameNumberOfGroups()
 {
     var target = new RoutingTable();
     var expectedFoo = typeof(int);
     var expectedBar = typeof(string);
     target.Add("/tests/{Id}/foo", expectedFoo);
     target.Add("/tests/{Id}/bar", expectedBar);
     IDictionary<string, string> variables;
     Assert.Equal(expectedFoo, target.Get("/tests/1/foo", out variables));
     Assert.Equal(expectedBar, target.Get("/tests/1/bar", out variables));
 }