public void on_action_executing_should_not_add_headers_for_versionX2Dneutral_controller() { // arrange var context = CreateContext(ApiVersionModel.Neutral); var attribute = new ReportApiVersionsAttribute(); // act attribute.OnActionExecuted(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_executed_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.OnActionExecuted(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"); }