Beispiel #1
0
        public void should_map_controller_should_return_expected_result_for_controller_version(int majorVersion, bool expected)
        {
            // arrange
            var configuration = new HttpConfiguration();
            var controller    = new HttpControllerDescriptor(configuration, string.Empty, typeof(ControllerV1));
            var convention    = new VersionedAttributeRoutingConvention("Tests", configuration, new ApiVersion(majorVersion, 0));

            // act
            var result = convention.ShouldMapController(controller);

            // assert
            result.Should().Be(expected);
        }
        public void select_action_should_return_true_for_versionX2Dneutral_controller()
        {
            // arrange
            var routeContext    = NewRouteContext("http://localhost/NeutralTests/1", typeof(VersionNeutralController));
            var serviceProvider = routeContext.HttpContext.RequestServices;
            var convention      = new VersionedAttributeRoutingConvention("odata", serviceProvider);

            // act
            var result = convention.SelectAction(routeContext);

            // assert
            result.Single().ActionName.Should().Be("Get");
        }
Beispiel #3
0
        public void should_map_controller_should_return_true_for_versionX2Dneutral_controller()
        {
            // arrange
            var configuration = new HttpConfiguration();
            var controller    = new HttpControllerDescriptor(configuration, string.Empty, typeof(NeutralController));
            var convention    = new VersionedAttributeRoutingConvention("Tests", configuration, new ApiVersion(1, 0));

            // act
            var result = convention.ShouldMapController(controller);

            // assert
            result.Should().BeTrue();
        }
        public void select_action_should_return_expected_result_for_controller_version(int majorVersion, string expected)
        {
            // arrange
            var apiVersion      = majorVersion + ".0";
            var routeContext    = NewRouteContext($"http://localhost/Tests(1)?api-version={apiVersion}", typeof(TestsController), apiVersion);
            var serviceProvider = routeContext.HttpContext.RequestServices;
            var convention      = new VersionedAttributeRoutingConvention("odata", serviceProvider);

            // act
            var actionName = convention.SelectAction(routeContext)?.SingleOrDefault()?.ActionName;

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