public void ShouldAddParameter_WhenDisplayAttributeIsSetAndHttpMethodIsIncluded(string httpMethod) { // Arrange var expectedParameter = new OpenApiParameter { Name = "If-Match", In = ParameterLocation.Header, Description = "Blah", Required = false, Schema = new OpenApiSchema { Type = "String" } }; var operationFilter = new RevisionHeaderParameterOperationFilter <RevisionContext>(); var operationFilterContext = GetOperationFilterContext(httpMethod); var openApiOperation = new OpenApiOperation(); // Act operationFilter.Apply(openApiOperation, operationFilterContext); // Assert openApiOperation.Parameters.Should().NotBeNullOrEmpty(); openApiOperation.Parameters.Should().ContainEquivalentOf(expectedParameter); }
public void ShouldDoNothing_WhenDisplayAttributeIsSetAndNameIsWhitespace() { // Arrange var operationFilter = new RevisionHeaderParameterOperationFilter <RevisionContextWhiteSpaceDipslayName>(); var operationFilterContext = GetOperationFilterContext("PUT"); var openApiOperation = new OpenApiOperation(); // Act operationFilter.Apply(openApiOperation, operationFilterContext); // Assert openApiOperation.Parameters.Should().BeNullOrEmpty(); }
public void ShouldDoNothing_WhenHttpMethodIsExcluded(string httpMethod) { // Arrange var operationFilter = new RevisionHeaderParameterOperationFilter <RevisionContext>(); var operationFilterContext = GetOperationFilterContext(httpMethod); var openApiOperation = new OpenApiOperation(); // Act operationFilter.Apply(openApiOperation, operationFilterContext); // Assert openApiOperation.Parameters.Should().BeNullOrEmpty(); }