Skip to content

Commit 2b82a74

Browse files
committed
Added more tests to meet the coverage gods
1 parent 230af2f commit 2b82a74

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,30 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram()
131131
Assert.Contains("graph LR", output);
132132
}
133133

134+
[Fact]
135+
public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagram()
136+
{
137+
var fileinfo = new FileInfo("sample.md");
138+
// create a dummy ILogger instance for testing
139+
await OpenApiService.ShowOpenApiDocument(null, "UtilityFiles\\Todo.xml", "todos", fileinfo, new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken());
140+
141+
var output = File.ReadAllText(fileinfo.FullName);
142+
Assert.Contains("graph LR", output);
143+
}
144+
145+
[Fact]
146+
public async Task ThrowIfURLIsNotResolvableWhenValidating()
147+
{
148+
var message = Assert.ThrowsAsync<InvalidOperationException>(async () =>
149+
await OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken()));
150+
}
151+
152+
[Fact]
153+
public async Task ThrowIfFileDoesNotExistWhenValidating()
154+
{
155+
var message = Assert.ThrowsAsync<InvalidOperationException>(async () =>
156+
await OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken()));
157+
}
134158

135159
[Fact]
136160
public async Task TransformCommandConvertsOpenApi()
@@ -175,8 +199,6 @@ public void InvokeShowCommand()
175199
}
176200

177201

178-
179-
180202
// Relatively useless test to keep the code coverage metrics happy
181203
[Fact]
182204
public void CreateRootCommand()

0 commit comments

Comments
 (0)