Пример #1
0
        public void apply_should_apply_configured_conventions()
        {
            // arrange
            var configuration        = new HttpConfiguration();
            var controllerDescriptor = new HttpControllerDescriptor(configuration, "Undecorated", typeof(v2.UndecoratedController));
            var conventionBuilder    = new ApiVersionConventionBuilder();

            conventionBuilder.Add(new VersionByNamespaceConvention());
            configuration.AddApiVersioning(o => o.Conventions = conventionBuilder);

            // act
            conventionBuilder.ApplyTo(controllerDescriptor);

            // assert
            controllerDescriptor.GetApiVersionModel().DeclaredApiVersions.Single().Should().Be(new ApiVersion(2, 0));
        }
Пример #2
0
        public void apply_should_apply_configured_conventions()
        {
            // arrange
            var configuration        = new HttpConfiguration();
            var controllerDescriptor = new HttpControllerDescriptor(configuration, "Undecorated", typeof(v2.UndecoratedController));
            var conventionBuilder    = new ApiVersionConventionBuilder();

            conventionBuilder.Add(new VersionByNamespaceConvention());
            configuration.AddApiVersioning(o => o.Conventions = conventionBuilder);

            var actionDescriptor = configuration.Services.GetActionSelector().GetActionMapping(controllerDescriptor).SelectMany(g => g).Single();

            // act
            conventionBuilder.ApplyTo(controllerDescriptor);

            // assert
            actionDescriptor.MappingTo(new ApiVersion(2, 0)).Should().Be(Implicit);
        }