File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed
TestableIO.System.IO.Abstractions.TestingHelpers
TestableIO.System.IO.Abstractions.Wrappers
TestableIO.System.IO.Abstractions
tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,10 @@ public override void Flush()
223
223
InternalFlush ( ) ;
224
224
}
225
225
226
+ /// <inheritdoc />
227
+ public override void Flush ( bool flushToDisk )
228
+ => InternalFlush ( ) ;
229
+
226
230
/// <inheritdoc />
227
231
public override Task FlushAsync ( CancellationToken cancellationToken )
228
232
{
Original file line number Diff line number Diff line change @@ -41,5 +41,9 @@ public void SetAccessControl(object value)
41
41
throw new ArgumentException ( "value must be of type `FileSecurity`" ) ;
42
42
}
43
43
}
44
+
45
+ /// <inheritdoc />
46
+ public override void Flush ( bool flushToDisk )
47
+ => fileStream . Flush ( flushToDisk ) ;
44
48
}
45
49
}
Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ public override void EndWrite(IAsyncResult asyncResult)
128
128
public override void Flush ( )
129
129
=> _stream . Flush ( ) ;
130
130
131
+ /// <inheritDoc cref="FileStream.Flush(bool)" />
132
+ public virtual void Flush ( bool flushToDisk )
133
+ => _stream . Flush ( ) ;
134
+
131
135
/// <inheritdoc cref="Stream.FlushAsync(CancellationToken)" />
132
136
public override Task FlushAsync ( CancellationToken cancellationToken )
133
137
=> _stream . FlushAsync ( cancellationToken ) ;
Original file line number Diff line number Diff line change @@ -206,5 +206,25 @@ public void MockFileStream_Flush_ShouldNotChangePosition()
206
206
Assert . AreEqual ( 200 , stream . Position ) ;
207
207
}
208
208
}
209
+
210
+ [ Test ]
211
+ public void MockFileStream_FlushBool_ShouldNotChangePosition ( [ Values ] bool flushToDisk )
212
+ {
213
+ // Arrange
214
+ var fileSystem = new MockFileSystem ( ) ;
215
+ var path = XFS . Path ( "C:\\ test" ) ;
216
+ fileSystem . AddFile ( path , new MockFileData ( new byte [ 0 ] ) ) ;
217
+
218
+ using ( var stream = fileSystem . FileInfo . New ( path ) . OpenWrite ( ) )
219
+ {
220
+ // Act
221
+ stream . Write ( new byte [ 400 ] , 0 , 400 ) ;
222
+ stream . Seek ( 200 , SeekOrigin . Begin ) ;
223
+ stream . Flush ( flushToDisk ) ;
224
+
225
+ // Assert
226
+ Assert . AreEqual ( 200 , stream . Position ) ;
227
+ }
228
+ }
209
229
}
210
230
}
You can’t perform that action at this time.
0 commit comments