Skip to content

Commit

Permalink
Add test to validate
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Mar 6, 2024
1 parent 9a47cb2 commit 9de2aec
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,21 @@ public void StreamShouldNotCloseIfLeaveStreamOpenSettingEqualsTrue()
reader.Read(stream, out _);
Assert.True(stream.CanRead);
}

[Fact]
public async void StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrue()
{
var memoryStream = new MemoryStream();
using var fileStream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml"));

await fileStream.CopyToAsync(memoryStream);
memoryStream.Position = 0;
var stream = memoryStream;

var reader = new OpenApiStreamReader(new() { LeaveStreamOpen = true });
_ = await reader.ReadAsync(stream);
stream.Seek(0, SeekOrigin.Begin); // does not throw an object disposed exception
Assert.True(stream.CanRead);
}
}
}

0 comments on commit 9de2aec

Please sign in to comment.