Esempio n. 1
0
        public void controller_should_not_allow_both_compileX2Dtime_and_runX2Dtime_conventions()
        {
            // arrange
            var conventionBuilder = new ApiVersionConventionBuilder();

            conventionBuilder.Controller <StubController>();

            // act
            Action controllerConvention = () => conventionBuilder.Controller(typeof(StubController));

            // assert
            controllerConvention.Should().Throw <InvalidOperationException>();
        }
Esempio n. 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);

            // act
            conventionBuilder.ApplyTo(controllerDescriptor);

            // assert
            controllerDescriptor.GetApiVersionModel().DeclaredApiVersions.Single().Should().Be(new ApiVersion(2, 0));
        }
Esempio n. 3
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);
        }