Пример #1
0
        public void WhenNoMatchThenNull()
        {
            var route   = new AbsoluteRoute("fixedvalue/{action}/{id}");
            var context = "http://acme.com/pizza".AsUri().ToHttpContext();

            route.GetRouteData(context).Should().Be.Null();
        }
Пример #2
0
        public void WhenNoMatchByConstraintsThenNull()
        {
            var route     = new AbsoluteRoute("{controller}/{action}/{id}", constraints: new RouteValueDictionary(new { controller = "nomatch" }));
            var context   = "http://acme.com/pizza/calda/1".AsUri().ToHttpContext();
            var routedata = route.GetRouteData(context);

            routedata.Should().Be.Null();
        }
Пример #3
0
        public void WhenNoMatchWithQueryStringThenNull()
        {
            var route     = new AbsoluteRoute("http://{*host}/{category}");
            var context   = "http://acme.com/?p=5".AsUri().ToHttpContext();
            var routedata = route.GetRouteData(context);

            routedata.Should().Be.Null();
        }
Пример #4
0
        public void WhenMatchThenAssignRoute()
        {
            var route     = new AbsoluteRoute("{controller}/{action}/{id}");
            var context   = "http://acme.com/pizza/calda/1".AsUri().ToHttpContext();
            var routedata = route.GetRouteData(context);

            routedata.Route.Should().Be.SameInstanceAs(route);
        }
Пример #5
0
        public void WhenMatchThenAssignValues()
        {
            var route     = new AbsoluteRoute("{controller}/{action}/{id}", constraints: new RouteValueDictionary(new { controller = "pazza|pizza" }));
            var context   = "http://acme.com/pizza/calda/1".AsUri().ToHttpContext();
            var routedata = route.GetRouteData(context);

            routedata.Values.Should().Not.Be.Null();
            routedata.Values["controller"].Should().Be("pizza");
            routedata.Values["action"].Should().Be("calda");
            routedata.Values["id"].Should().Be("1");
        }
Пример #6
0
        public void WhenMatchThenCopyDataTokens()
        {
            var route     = new AbsoluteRoute("{controller}/{action}/{id}", dataTokens: new RouteValueDictionary(new { a = 1, b = 2 }));
            var context   = "http://acme.com/pizza/calda/1".AsUri().ToHttpContext();
            var routedata = route.GetRouteData(context);
            var tokens    = routedata.DataTokens;

            tokens.Should().Not.Be.Null();
            tokens["a"].Should().Be(1);
            tokens["b"].Should().Be(2);
        }