Skip to content

Commit

Permalink
fix: async dispose for FileSystemStream (#1163)
Browse files Browse the repository at this point in the history
Fix #1162
  • Loading branch information
vbreuss authored Nov 8, 2024
1 parent 17464e6 commit 4ef1c3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/TestableIO.System.IO.Abstractions/FileSystemStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4ef1c3a

Please sign in to comment.