Ejemplo n.º 1
0
        public void Given_NoComplexTypePathParameter_Router_Returns_DefaultTypedRouteParameter()
        {
            // Arrange
            string requestPath = "/api/testing/router/";
            string pathPattern = "^/api/testing/router/";
            Type   targetType  = typeof(TestType);

            // Act
            object pathParameter = GuardianRouter.GetTypedRouteParameter(requestPath, pathPattern, targetType);

            // Assert
            pathParameter.Should().BeNull();
        }
Ejemplo n.º 2
0
        public void Given_Null_PathPattern_Router_Returns_NullRouteParameter()
        {
            // Arrange
            string requestPath = "/api/testing/router";
            string pathPattern = null;
            Type   targetType  = typeof(string);

            // Act
            object pathParameter = GuardianRouter.GetTypedRouteParameter(requestPath, pathPattern, targetType);

            // Assert
            pathParameter.Should().BeNull();
        }
Ejemplo n.º 3
0
        public void Given_IntPathParameter_Router_Returns_TypedRouteParameter()
        {
            // Arrange
            string requestPath = "/api/testing/router/123";
            string pathPattern = "^/api/testing/router/";
            Type   targetType  = typeof(int);

            // Act
            object pathParameter = GuardianRouter.GetTypedRouteParameter(requestPath, pathPattern, targetType);

            // Assert
            pathParameter.Should().NotBeNull();
            pathParameter.GetType().Should().Be(targetType);
            ((int)pathParameter).Should().Be(123);
        }