Skip to content

Commit

Permalink
feat: support Flush(bool flushToDisk) (#307)
Browse files Browse the repository at this point in the history
Add support for `Flush(bool)` added in
TestableIO/System.IO.Abstractions#985

---------

Co-authored-by: Valentin Breuß <v.breuss@tig.at>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 12, 2023
1 parent b50ef2b commit 7300547
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public override void Flush()
InternalFlush();
}

/// <inheritdoc cref="FileSystemStream.Flush(bool)" />
public override void Flush(bool flushToDisk)
=> Flush();

/// <inheritdoc cref="FileSystemStream.FlushAsync(CancellationToken)" />
public override Task FlushAsync(CancellationToken cancellationToken)
{
Expand Down
16 changes: 16 additions & 0 deletions Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ public void Flush_ShouldNotChangePosition(
stream.Position.Should().Be(2);
}

[SkippableTheory]
[InlineAutoData(false)]
[InlineAutoData(true)]
public void Flush_WriteToDisk_ShouldNotChangePosition(
bool flushToDisk, string path, byte[] bytes)
{
using FileSystemStream stream = FileSystem.File.Create(path);
stream.Write(bytes, 0, bytes.Length);
stream.Seek(2, SeekOrigin.Begin);
stream.Position.Should().Be(2);

stream.Flush(flushToDisk);

stream.Position.Should().Be(2);
}

[SkippableTheory]
[AutoData]
public void Flush_ShouldNotUpdateFileContentWhenAlreadyFlushed(
Expand Down

0 comments on commit 7300547

Please sign in to comment.