Ejemplo n.º 1
0
        public void Should_not_match_when_value_is_not_in_range()
        {
            var constraint = new RangeConstraint<int>(1, 5);

            var matched = constraint.Match(new Mock<HttpContextBase>().Object, new Route("{controller}/{action}", new Mock<IRouteHandler>().Object), "page", new RouteValueDictionary { { "page", 6 } }, RouteDirection.IncomingRequest);

            Assert.False(matched);
        }
Ejemplo n.º 2
0
        public void Should_match_when_parameter_is_optional()
        {
            var constraint = new RangeConstraint<int>(1, 5, true);

            var matched = constraint.Match(new Mock<HttpContextBase>().Object, new Route("{controller}/{action}", new Mock<IRouteHandler>().Object), "alias", new RouteValueDictionary { { "alias", null } }, RouteDirection.IncomingRequest);

            Assert.True(matched);
        }
Ejemplo n.º 3
0
        public void Should_not_match_when_unable_to_convert()
        {
            var constraint = new RangeConstraint <int>(1, 5);

            var matched = constraint.Match(new Mock <HttpContextBase>().Object, new Route("{controller}/{action}", new Mock <IRouteHandler>().Object), "page", new RouteValueDictionary {
                { "page", "xyz" }
            }, RouteDirection.IncomingRequest);

            Assert.False(matched);
        }
Ejemplo n.º 4
0
        public void Should_match_when_value_is_in_range()
        {
            var constraint = new RangeConstraint <int>(1, 5, true);

            var matched = constraint.Match(new Mock <HttpContextBase>().Object, new Route("{controller}/{action}", new Mock <IRouteHandler>().Object), "page", new RouteValueDictionary {
                { "page", 3 }
            }, RouteDirection.IncomingRequest);

            Assert.True(matched);
        }
Ejemplo n.º 5
0
        public void Should_match_when_parameter_is_optional()
        {
            var constraint = new RangeConstraint <int>(1, 5, true);

            var matched = constraint.Match(new Mock <HttpContextBase>().Object, new Route("{controller}/{action}", new Mock <IRouteHandler>().Object), "alias", new RouteValueDictionary {
                { "alias", null }
            }, RouteDirection.IncomingRequest);

            Assert.True(matched);
        }