Skip to content

Commit

Permalink
Added more tests to meet the coverage gods
Browse files Browse the repository at this point in the history
  • Loading branch information
darrelmiller committed Jan 16, 2023
1 parent 230af2f commit 2b82a74
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,30 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram()
Assert.Contains("graph LR", output);
}

[Fact]
public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagram()
{
var fileinfo = new FileInfo("sample.md");
// create a dummy ILogger instance for testing
await OpenApiService.ShowOpenApiDocument(null, "UtilityFiles\\Todo.xml", "todos", fileinfo, new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken());

var output = File.ReadAllText(fileinfo.FullName);
Assert.Contains("graph LR", output);
}

[Fact]
public async Task ThrowIfURLIsNotResolvableWhenValidating()
{
var message = Assert.ThrowsAsync<InvalidOperationException>(async () =>
await OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken()));
}

[Fact]
public async Task ThrowIfFileDoesNotExistWhenValidating()
{
var message = Assert.ThrowsAsync<InvalidOperationException>(async () =>
await OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken()));
}

[Fact]
public async Task TransformCommandConvertsOpenApi()
Expand Down Expand Up @@ -175,8 +199,6 @@ public void InvokeShowCommand()
}




// Relatively useless test to keep the code coverage metrics happy
[Fact]
public void CreateRootCommand()
Expand Down

0 comments on commit 2b82a74

Please sign in to comment.