public async Task on_action_executing_should_add_version_headers()
        {
            // arrange
            var supported       = new[] { new ApiVersion(1, 0), new ApiVersion(2, 0) };
            var deprecated      = new[] { new ApiVersion(0, 5) };
            var model           = new ApiVersionModel(supported, deprecated);
            var onStartResponse = new List <(Func <object, Task>, object)>();
            var context         = CreateContext(model, onStartResponse);
            var attribute       = new ReportApiVersionsAttribute();

            // act
            attribute.OnActionExecuting(context);

            for (var i = 0; i < onStartResponse.Count; i++)
            {
                var(callback, state) = onStartResponse[i];
                await callback(state);
            }

            // assert
            var headers = context.HttpContext.Response.Headers;

            headers["api-supported-versions"].Single().Should().Be("1.0, 2.0");
            headers["api-deprecated-versions"].Single().Should().Be("0.5");
        }
        public void on_action_executing_should_not_add_headers_for_versionX2Dneutral_controller()
        {
            // arrange
            var context   = CreateContext(ApiVersionModel.Neutral);
            var attribute = new ReportApiVersionsAttribute();

            // act
            attribute.OnActionExecuting(context);


            // assert
            context.HttpContext.Response.Headers.ContainsKey("api-supported-versions").Should().BeFalse();
            context.HttpContext.Response.Headers.ContainsKey("api-deprecated-versions").Should().BeFalse();
        }
        public void on_action_executing_should_add_version_headers()
        {
            // arrange
            var supported  = new[] { new ApiVersion(1, 0), new ApiVersion(2, 0) };
            var deprecated = new[] { new ApiVersion(0, 5) };
            var model      = new ApiVersionModel(supported, deprecated);
            var context    = CreateContext(model);
            var attribute  = new ReportApiVersionsAttribute();

            // act
            attribute.OnActionExecuting(context);

            // assert
            context.HttpContext.Response.Headers["api-supported-versions"].Single().Should().Be("1.0, 2.0");
            context.HttpContext.Response.Headers["api-deprecated-versions"].Single().Should().Be("0.5");
        }
        public async Task on_action_executing_should_not_add_headers_for_versionX2Dneutral_controller()
        {
            // arrange
            var onStartResponse = new List <(Func <object, Task>, object)>();
            var context         = CreateContext(ApiVersionModel.Neutral, onStartResponse);
            var attribute       = new ReportApiVersionsAttribute();

            // act
            attribute.OnActionExecuting(context);

            for (var i = 0; i < onStartResponse.Count; i++)
            {
                var(callback, state) = onStartResponse[i];
                await callback(state);
            }

            // assert
            var headers = context.HttpContext.Response.Headers;

            headers.ContainsKey("api-supported-versions").Should().BeFalse();
            headers.ContainsKey("api-deprecated-versions").Should().BeFalse();
        }