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()
223223 InternalFlush ( ) ;
224224 }
225225
226+ /// <inheritdoc />
227+ public override void Flush ( bool flushToDisk )
228+ => InternalFlush ( ) ;
229+
226230 /// <inheritdoc />
227231 public override Task FlushAsync ( CancellationToken cancellationToken )
228232 {
Original file line number Diff line number Diff line change @@ -41,5 +41,9 @@ public void SetAccessControl(object value)
4141 throw new ArgumentException ( "value must be of type `FileSecurity`" ) ;
4242 }
4343 }
44+
45+ /// <inheritdoc />
46+ public override void Flush ( bool flushToDisk )
47+ => fileStream . Flush ( flushToDisk ) ;
4448 }
4549}
Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ public override void EndWrite(IAsyncResult asyncResult)
128128 public override void Flush ( )
129129 => _stream . Flush ( ) ;
130130
131+ /// <inheritDoc cref="FileStream.Flush(bool)" />
132+ public virtual void Flush ( bool flushToDisk )
133+ => _stream . Flush ( ) ;
134+
131135 /// <inheritdoc cref="Stream.FlushAsync(CancellationToken)" />
132136 public override Task FlushAsync ( CancellationToken cancellationToken )
133137 => _stream . FlushAsync ( cancellationToken ) ;
Original file line number Diff line number Diff line change @@ -206,5 +206,25 @@ public void MockFileStream_Flush_ShouldNotChangePosition()
206206 Assert . AreEqual ( 200 , stream . Position ) ;
207207 }
208208 }
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+ }
209229 }
210230}
You can’t perform that action at this time.
0 commit comments