public void version_neutral_should_be_false_by_default()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            var versionNeutral = controllerBuilder.ProtectedVersionNeutral;

            // assert
            versionNeutral.Should().BeFalse();
        }
        public void is_api_version_neutral_should_update_backing_property()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.IsApiVersionNeutral();

            // assert
            controllerBuilder.ProtectedVersionNeutral.Should().BeTrue();
        }
        public void has_api_version_should_add_group_version_parts_with_status()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.HasApiVersion(2016, 9, 10, "alpha");

            // assert
            controllerBuilder.ProtectedSupportedVersions.Single().Should().Be(new ApiVersion(new DateTime(2016, 9, 10), "alpha"));
        }
        public void advertises_deprecated_api_version_should_add_major_and_minor_version_with_status()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.AdvertisesDeprecatedApiVersion(1, 5, "rc");

            // assert
            controllerBuilder.ProtectedDeprecatedAdvertisedVersions.Single().Should().Be(new ApiVersion(1, 5, "rc"));
        }
        public void has_api_version_should_add_major_and_minor_version_with_status()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.HasApiVersion(1, 5, "rc");

            // assert
            controllerBuilder.ProtectedSupportedVersions.Single().Should().Be(new ApiVersion(1, 5, "rc"));
        }
        public void advertises_deprecated_api_version_should_add_group_version_parts()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.AdvertisesDeprecatedApiVersion(2016, 9, 10);

            // assert
            controllerBuilder.ProtectedDeprecatedAdvertisedVersions.Single().Should().Be(new ApiVersion(new DateTime(2016, 9, 10)));
        }
        public void advertises_api_version_should_add_major_and_minor_version()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.AdvertisesApiVersion(1, 5);

            // assert
            controllerBuilder.ProtectedAdvertisedVersions.Single().Should().Be(new ApiVersion(1, 5));
        }
        public void has_deprecated_api_version_should_add_major_version_with_status()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.HasDeprecatedApiVersion(1, "beta");

            // assert
            controllerBuilder.ProtectedDeprecatedVersions.Single().Should().Be(new ApiVersion(1, 0, "beta"));
        }
        public void action_should_add_new_action_convention_builder()
        {
            // arrange
            var method            = typeof(UndecoratedController).GetMethod(nameof(UndecoratedController.Get));
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            var actionBuilder = controllerBuilder.Action(method);

            // assert
            controllerBuilder.ProtectedActionBuilders.Single().Should().BeSameAs(actionBuilder);
        }
        public void advertises_deprecated_api_versions_should_add_multiple_api_versions()
        {
            // arrange
            var apiVersions       = new[] { new ApiVersion(1, 0), new ApiVersion(2, 0), new ApiVersion(3, 0) };
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.AdvertisesDeprecatedApiVersions(apiVersions);

            // assert
            controllerBuilder.ProtectedDeprecatedAdvertisedVersions.Should().BeEquivalentTo(new[] { new ApiVersion(1, 0), new ApiVersion(2, 0), new ApiVersion(3, 0) });
        }
        public void advertises_api_version_should_add_group_version_with_status()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();
            var groupVersion      = new DateTime(2016, 9, 10);

            // act
            controllerBuilder.AdvertisesApiVersion(groupVersion, "alpha");

            // assert
            controllerBuilder.ProtectedAdvertisedVersions.Single().Should().Be(new ApiVersion(groupVersion, "alpha"));
        }
        public void has_deprecated_api_version_should_add_group_version()
        {
            // arrange
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();
            var groupVersion      = new DateTime(2016, 9, 10);

            // act
            controllerBuilder.HasDeprecatedApiVersion(groupVersion);

            // assert
            controllerBuilder.ProtectedDeprecatedVersions.Single().Should().Be(new ApiVersion(groupVersion));
        }
        public void has_api_versions_should_add_multiple_api_versions()
        {
            // arrange
            var apiVersions       = new[] { new ApiVersion(1, 0), new ApiVersion(2, 0), new ApiVersion(3, 0) };
            var controllerBuilder = new TestControllerApiVersionConventionBuilder();

            // act
            controllerBuilder.HasApiVersions(apiVersions);

            // assert
            controllerBuilder.ProtectedSupportedVersions.Should().BeEquivalentTo(new[] { new ApiVersion(1, 0), new ApiVersion(2, 0), new ApiVersion(3, 0) });
        }
        public void action_should_return_existing_action_convention_builder()
        {
            // arrange
            var method                = typeof(UndecoratedController).GetMethod(nameof(UndecoratedController.Get));
            var controllerBuilder     = new TestControllerApiVersionConventionBuilder();
            var originalActionBuilder = controllerBuilder.Action(method);

            // act
            var actionBuilder = controllerBuilder.Action(method);

            // assert
            actionBuilder.Should().BeSameAs(originalActionBuilder);
            controllerBuilder.ProtectedActionBuilders.Values.Single().Should().BeSameAs(actionBuilder);
        }