Skip to content

Commit 38b4f7c

Browse files
committed
Prepare changes for support of Flush(bool flushToDisk) in System.IO.Abstractions
1 parent 902d190 commit 38b4f7c

File tree

2 files changed

+20
-0
lines changed
  • Source/Testably.Abstractions.Testing/FileSystem
  • Tests/Testably.Abstractions.Tests/FileSystem/FileStream

2 files changed

+20
-0
lines changed

Source/Testably.Abstractions.Testing/FileSystem/FileStreamMock.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ public override void Flush()
189189
InternalFlush();
190190
}
191191

192+
/// <inheritdoc cref="FileSystemStream.Flush(bool)" />
193+
public override void Flush(bool flushToDisk)
194+
=> Flush();
195+
192196
/// <inheritdoc cref="FileSystemStream.FlushAsync(CancellationToken)" />
193197
public override Task FlushAsync(CancellationToken cancellationToken)
194198
{

Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,22 @@ public void Flush_ShouldNotChangePosition(
162162
stream.Position.Should().Be(2);
163163
}
164164

165+
[SkippableTheory]
166+
[InlineAutoData(false)]
167+
[InlineAutoData(true)]
168+
public void Flush_WriteToDisk_ShouldNotChangePosition(
169+
bool flushToDisk, string path, byte[] bytes)
170+
{
171+
using FileSystemStream stream = FileSystem.File.Create(path);
172+
stream.Write(bytes, 0, bytes.Length);
173+
stream.Seek(2, SeekOrigin.Begin);
174+
stream.Position.Should().Be(2);
175+
176+
stream.Flush(flushToDisk);
177+
178+
stream.Position.Should().Be(2);
179+
}
180+
165181
[SkippableTheory]
166182
[AutoData]
167183
public void Flush_ShouldNotUpdateFileContentWhenAlreadyFlushed(

0 commit comments

Comments
 (0)