Skip to content

Commit

Permalink
Update OpenApiServiceTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 2, 2023
1 parent 508dc0a commit 35851e0
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram()
Output = new FileInfo("sample.md")
};

await OpenApiService.ShowOpenApiDocument(options, _logger, new CancellationToken());
await OpenApiService.ShowOpenApiDocument(options, _logger);

var output = await File.ReadAllTextAsync(options.Output.FullName);
Assert.Contains("graph LR", output, StringComparison.Ordinal);
Expand All @@ -155,7 +155,7 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram()
{
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml")
};
var filePath = await OpenApiService.ShowOpenApiDocument(options, _logger, new CancellationToken());
var filePath = await OpenApiService.ShowOpenApiDocument(options, _logger);
Assert.True(File.Exists(filePath));
}

Expand All @@ -170,7 +170,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag
};

// create a dummy ILogger instance for testing
await OpenApiService.ShowOpenApiDocument(options, _logger, new CancellationToken());
await OpenApiService.ShowOpenApiDocument(options, _logger);

var output = await File.ReadAllTextAsync(options.Output.FullName);
Assert.Contains("graph LR", output, StringComparison.Ordinal);
Expand All @@ -180,29 +180,29 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag
public async Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating()
{
await Assert.ThrowsAsync<ArgumentNullException>(async () =>
await OpenApiService.ValidateOpenApiDocument("", _logger, new CancellationToken()));
await OpenApiService.ValidateOpenApiDocument("", _logger));
}


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

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

[Fact]
public async Task ValidateCommandProcessesOpenApi()
{
// create a dummy ILogger instance for testing
await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, new CancellationToken());
await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger);

Assert.True(true);
}
Expand All @@ -221,7 +221,7 @@ public async Task TransformCommandConvertsOpenApi()
InlineExternal = false,
};
// create a dummy ILogger instance for testing
await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken());
await OpenApiService.TransformOpenApiDocument(options, _logger);

var output = await File.ReadAllTextAsync("sample.json");
Assert.NotEmpty(output);
Expand All @@ -240,7 +240,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputName()
InlineExternal = false,
};
// create a dummy ILogger instance for testing
await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken());
await OpenApiService.TransformOpenApiDocument(options, _logger);

var output = await File.ReadAllTextAsync("output.yml");
Assert.NotEmpty(output);
Expand All @@ -258,7 +258,7 @@ public async Task TransformCommandConvertsCsdlWithDefaultOutputName()
InlineExternal = false,
};
// create a dummy ILogger instance for testing
await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken());
await OpenApiService.TransformOpenApiDocument(options, _logger);

var output = await File.ReadAllTextAsync("output.yml");
Assert.NotEmpty(output);
Expand All @@ -278,7 +278,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
InlineExternal = false,
};
// create a dummy ILogger instance for testing
await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken());
await OpenApiService.TransformOpenApiDocument(options, _logger);

var output = await File.ReadAllTextAsync("output.yml");
Assert.NotEmpty(output);
Expand All @@ -295,7 +295,7 @@ public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
InlineExternal = false,
};
await Assert.ThrowsAsync<ArgumentException>(async () =>
await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken()));
await OpenApiService.TransformOpenApiDocument(options, _logger));

}

Expand All @@ -315,7 +315,7 @@ public async Task TransformToPowerShellCompliantOpenApi()
SettingsConfig = SettingsUtilities.GetConfiguration(settingsPath)
};
// create a dummy ILogger instance for testing
await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken());
await OpenApiService.TransformOpenApiDocument(options, _logger);

var output = await File.ReadAllTextAsync("output.yml");
Assert.NotEmpty(output);
Expand Down

0 comments on commit 35851e0

Please sign in to comment.