Ejemplo n.º 1
0
        public void StringRouteConstraintKeyNotFoundWithRouteDirectionIncomingRequestTest()
        {
            // Arrange
            var constraint = new StringRouteConstraint("admin");

            // Act
            var values = new RouteValueDictionary(new { controller = "admin" });

            var match = constraint.Match(
                new DefaultHttpContext(),
                route: new Mock <IRouter>().Object,
                routeKey: "action",
                values: values,
                routeDirection: RouteDirection.IncomingRequest);

            // Assert
            Assert.False(match);
        }
Ejemplo n.º 2
0
        public void StringRouteConstraintEscapingCaseSensitiveAndRouteNullTest(string routeValue, string constraintValue, bool expected)
        {
            // Arrange
            var constraint = new StringRouteConstraint(constraintValue);

            // Act
            var values = new RouteValueDictionary(new { controller = routeValue });

            var match = constraint.Match(
                new DefaultHttpContext(),
                route: new Mock <IRouter>().Object,
                routeKey: "controller",
                values: values,
                routeDirection: RouteDirection.IncomingRequest);

            // Assert
            Assert.Equal(expected, match);
        }
Ejemplo n.º 3
0
        public void StringRouteConstraintSimpleFalseWithRouteDirectionUrlGenerationTest()
        {
            // Arrange
            var constraint = new StringRouteConstraint("admin");

            // Act
            var values = new RouteValueDictionary(new { controller = "home" });

            var match = constraint.Match(
                new DefaultHttpContext(),
                route: new Mock <IRouter>().Object,
                routeKey: "controller",
                values: values,
                routeDirection: RouteDirection.UrlGeneration);

            // Assert
            Assert.False(match);
        }
Ejemplo n.º 4
0
        public void StringRouteConstraintSimpleTrueWithRouteDirectionIncomingRequestTest()
        {
            // Arrange
            var constraint = new StringRouteConstraint("home");

            // Act
            var values = new RouteValueDictionary(new { controller = "home" });

            var match = constraint.Match(
                new DefaultHttpContext(),
                route: new Mock <IRouter>().Object,
                routeKey: "controller",
                values: values,
                routeDirection: RouteDirection.IncomingRequest);

            // Assert
            Assert.True(match);
        }