示例#1
0
        public void match_should_return_false_when_route_parameter_is_missing()
        {
            // arrange
            var request        = new HttpRequestMessage();
            var route          = new Mock <IHttpRoute>().Object;
            var values         = new Dictionary <string, object>();
            var routeDirection = UriResolution;
            var constraint     = new ApiVersionRouteConstraint();

            // act
            var matched = constraint.Match(request, route, "version", values, routeDirection);

            // assert
            matched.Should().BeFalse();
        }
示例#2
0
        public void match_should_return_true_when_matched()
        {
            // arrange
            var request = new HttpRequestMessage();
            var route   = new Mock <IHttpRoute>().Object;
            var values  = new Dictionary <string, object>()
            {
                ["version"] = "2.0"
            };
            var routeDirection = UriResolution;
            var constraint     = new ApiVersionRouteConstraint();

            // act
            var matched = constraint.Match(request, route, "version", values, routeDirection);

            // assert
            matched.Should().BeTrue();
        }
示例#3
0
        public void match_should_return_expected_result_for_url_generation(string key, string value, bool expected)
        {
            // arrange
            var request        = new HttpRequestMessage();
            var route          = new Mock <IHttpRoute>().Object;
            var values         = new Dictionary <string, object>();
            var routeDirection = UriGeneration;
            var constraint     = new ApiVersionRouteConstraint();

            if (!IsNullOrEmpty(key))
            {
                values[key] = value;
            }

            // act
            var matched = constraint.Match(request, route, key, values, routeDirection);

            // assert
            matched.Should().Be(expected);
        }