Skip to content

Commit 96fae88

Browse files
committed
Will these be the tests that achieve the magical goal?
1 parent 4537239 commit 96fae88

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ private static void WriteOpenApi(FileInfo output, bool terseOutput, bool inlineL
103103
{
104104
using (logger.BeginScope("Output"))
105105
{
106-
using var outputStream = output?.Create();
107-
var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out;
106+
using var outputStream = output.Create();
107+
var textWriter = new StreamWriter(outputStream);
108108

109109
var settings = new OpenApiWriterSettings()
110110
{

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,26 @@ public async Task TransformCommandConvertsOpenApi()
185185
Assert.NotEmpty(output);
186186
}
187187

188+
[Fact]
189+
public async Task TransformCommandConvertsOpenApiWithDefaultOutputname()
190+
{
191+
// create a dummy ILogger instance for testing
192+
await OpenApiService.TransformOpenApiDocument("UtilityFiles\\SampleOpenApi.yml", null, null, null, true, null, null, false, null, false, false, null, null, null, new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken());
193+
194+
var output = File.ReadAllText("output.yml");
195+
Assert.NotEmpty(output);
196+
}
197+
198+
[Fact]
199+
public async Task TransformCommandConvertsOpenApiWithDefaultOutputnameAndSwitchFormat()
200+
{
201+
// create a dummy ILogger instance for testing
202+
await OpenApiService.TransformOpenApiDocument("UtilityFiles\\SampleOpenApi.yml", null, null, null, true, "3.0", OpenApiFormat.Yaml, false, null, false, false, null, null, null, new Logger<OpenApiService>(new LoggerFactory()), new CancellationToken());
203+
204+
var output = File.ReadAllText("output.yml");
205+
Assert.NotEmpty(output);
206+
}
207+
188208
[Fact]
189209
public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
190210
{

0 commit comments

Comments
 (0)