Skip to content

Commit 598f2b6

Browse files
author
Iván Canales Martín
committed
Create test for bug
1 parent 6899d5f commit 598f2b6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,46 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen
6565
Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count);
6666
}
6767

68+
[Fact]
69+
public void CreateFilteredDocumentOnMinimalOpenApi()
70+
{
71+
// Arrange
72+
73+
// We create a minimal OpenApiDocument with a single path and operation.
74+
var openApiDoc = new OpenApiDocument
75+
{
76+
Info = new()
77+
{
78+
Title = "Test",
79+
Version = "1.0.0"
80+
},
81+
Paths = new()
82+
{
83+
["/test"] = new OpenApiPathItem()
84+
{
85+
Operations = new Dictionary<OperationType, OpenApiOperation>
86+
{
87+
[OperationType.Get] = new OpenApiOperation()
88+
}
89+
}
90+
}
91+
};
92+
93+
// Act
94+
var requestUrls = new Dictionary<string, List<string>>()
95+
{
96+
{ "/test", ["GET"] }
97+
};
98+
var filterPredicate = OpenApiFilterService.CreatePredicate(null, null, requestUrls, openApiDoc);
99+
var filteredDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, filterPredicate);
100+
101+
// Assert
102+
Assert.NotNull(filteredDocument);
103+
Assert.NotNull(filteredDocument.Paths);
104+
Assert.Single(filteredDocument.Paths);
105+
}
106+
107+
68108
[Theory]
69109
[InlineData("UtilityFiles/appsettingstest.json")]
70110
[InlineData(null)]

0 commit comments

Comments
 (0)