Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: async dispose for FileSystemStream #1163

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/TestableIO.System.IO.Abstractions/FileSystemStream.cs
Original file line number Diff line number Diff line change
@@ -223,15 +223,6 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

#if FEATURE_ASYNC_FILE
/// <inheritdoc cref="Stream.DisposeAsync()" />
public override async ValueTask DisposeAsync()
{
await _stream.DisposeAsync();
await base.DisposeAsync();
}
#endif

/// <summary>
/// Allows to cast the internal Stream to a FileStream
/// </summary>
Original file line number Diff line number Diff line change
@@ -283,6 +283,18 @@ public void MockFileStream_Null_ShouldReturnSingletonObject()

Assert.That(result1, Is.SameAs(result2));
}

#if FEATURE_ASYNC_FILE
[Test]
public async Task MockFileStream_DisposeAsync_ShouldNotThrow()
{
var fileSystem = new MockFileSystem();
fileSystem.File.WriteAllText("foo.txt", "");
{
await using var reportStream = fileSystem.File.OpenRead("foo.txt");
}
}
#endif

[Test]
public void MockFileStream_Null_ShouldHaveExpectedProperties()
Loading