@@ -105,14 +105,14 @@ public async Task MockFileStream_SharedFileContents_ShouldBeVisible()
105105 for ( int ix = 0 ; ix < 3 ; ix ++ )
106106 {
107107 file1 . Position = 0 ;
108- file1 . Write ( BitConverter . GetBytes ( ix ) ) ;
108+ file1 . Write ( BitConverter . GetBytes ( ix ) , 0 , 4 ) ;
109109 file1 . Flush ( ) ;
110110
111111 file2 . Position = 0 ;
112112 file2 . Flush ( ) ;
113- var bytesRead = file2 . Read ( buffer ) ;
113+ var bytesRead = file2 . Read ( buffer , 0 , buffer . Length ) ;
114114 await That ( bytesRead ) . IsEqualTo ( 4 ) . Because ( "should read exactly 4 bytes" ) ;
115- int readValue = BitConverter . ToInt32 ( buffer ) ;
115+ int readValue = BitConverter . ToInt32 ( buffer , 0 ) ;
116116
117117 await That ( readValue ) . IsEqualTo ( ix )
118118 . Because ( $ "file2 should read the value { ix } that was written by file1, but got { readValue } ") ;
@@ -136,13 +136,13 @@ public async Task MockFileStream_SharedContent_SetLengthTruncation_ShouldBeVisib
136136 using var file2 = fileSystem . FileStream . New ( filename , FileMode . Open , FileAccess . ReadWrite , FileShare . ReadWrite ) ;
137137
138138 // Write initial data
139- file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ) ;
139+ file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } , 0 , 8 ) ;
140140 file1 . Flush ( ) ;
141141
142142 // Verify file2 can see the data
143143 file2 . Position = 0 ;
144144 var buffer = new byte [ 8 ] ;
145- var bytesRead = file2 . Read ( buffer ) ;
145+ var bytesRead = file2 . Read ( buffer , 0 , buffer . Length ) ;
146146 await That ( bytesRead ) . IsEqualTo ( 8 ) ;
147147
148148 // Truncate file via file1
@@ -152,7 +152,7 @@ public async Task MockFileStream_SharedContent_SetLengthTruncation_ShouldBeVisib
152152 // Verify file2 sees the truncation
153153 file2 . Position = 0 ;
154154 buffer = new byte [ 8 ] ;
155- bytesRead = file2 . Read ( buffer ) ;
155+ bytesRead = file2 . Read ( buffer , 0 , buffer . Length ) ;
156156 await That ( bytesRead ) . IsEqualTo ( 4 )
157157 . Because ( "file2 should see truncated length" ) ;
158158 await That ( buffer . Take ( 4 ) . ToArray ( ) ) . IsEquivalentTo ( new byte [ ] { 1 , 2 , 3 , 4 } ) ;
@@ -175,7 +175,7 @@ public async Task MockFileStream_SharedContent_PositionBeyondFileBounds_ShouldHa
175175 using var file2 = fileSystem . FileStream . New ( filename , FileMode . Open , FileAccess . ReadWrite , FileShare . ReadWrite ) ;
176176
177177 // Write some data and position file2 beyond it
178- file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 } ) ;
178+ file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 } , 0 , 4 ) ;
179179 file1 . Flush ( ) ;
180180
181181 file2 . Position = 10 ; // Beyond file end
@@ -186,7 +186,7 @@ public async Task MockFileStream_SharedContent_PositionBeyondFileBounds_ShouldHa
186186
187187 // file2 position should be adjusted
188188 var buffer = new byte [ 4 ] ;
189- var bytesRead = file2 . Read ( buffer ) ;
189+ var bytesRead = file2 . Read ( buffer , 0 , buffer . Length ) ;
190190 await That ( bytesRead ) . IsEqualTo ( 0 )
191191 . Because ( "reading beyond file end should return 0 bytes" ) ;
192192 await That ( file2 . Position ) . IsLessThanOrEqualTo ( file2 . Length )
@@ -215,23 +215,23 @@ public async Task MockFileStream_SharedContent_ConcurrentWritesToDifferentPositi
215215
216216 // Write to different positions
217217 file1 . Position = 0 ;
218- file1 . Write ( new byte [ ] { 1 , 1 , 1 , 1 } ) ;
218+ file1 . Write ( new byte [ ] { 1 , 1 , 1 , 1 } , 0 , 4 ) ;
219219 file1 . Flush ( ) ;
220220
221221 file2 . Position = 10 ;
222- file2 . Write ( new byte [ ] { 2 , 2 , 2 , 2 } ) ;
222+ file2 . Write ( new byte [ ] { 2 , 2 , 2 , 2 } , 0 , 4 ) ;
223223 file2 . Flush ( ) ;
224224
225225 // Verify both writes are visible
226226 file1 . Position = 10 ;
227227 var buffer1 = new byte [ 4 ] ;
228- var bytesRead1 = file1 . Read ( buffer1 ) ;
228+ var bytesRead1 = file1 . Read ( buffer1 , 0 , buffer1 . Length ) ;
229229 await That ( bytesRead1 ) . IsEqualTo ( 4 ) ;
230230 await That ( buffer1 ) . IsEquivalentTo ( new byte [ ] { 2 , 2 , 2 , 2 } ) ;
231231
232232 file2 . Position = 0 ;
233233 var buffer2 = new byte [ 4 ] ;
234- var bytesRead2 = file2 . Read ( buffer2 ) ;
234+ var bytesRead2 = file2 . Read ( buffer2 , 0 , buffer2 . Length ) ;
235235 await That ( bytesRead2 ) . IsEqualTo ( 4 ) ;
236236 await That ( buffer2 ) . IsEquivalentTo ( new byte [ ] { 1 , 1 , 1 , 1 } ) ;
237237 }
@@ -252,19 +252,19 @@ public async Task MockFileStream_SharedContent_ReadOnlyStreamShouldRefresh()
252252
253253 // Verify initial content
254254 var buffer = new byte [ 7 ] ;
255- var bytesRead = readStream . Read ( buffer ) ;
255+ var bytesRead = readStream . Read ( buffer , 0 , buffer . Length ) ;
256256 await That ( bytesRead ) . IsEqualTo ( 7 ) ;
257257 await That ( System . Text . Encoding . UTF8 . GetString ( buffer ) ) . IsEqualTo ( "initial" ) ;
258258
259259 // Write new content
260260 writeStream . Position = 0 ;
261- writeStream . Write ( System . Text . Encoding . UTF8 . GetBytes ( "updated" ) ) ;
261+ var updatedBytes = System . Text . Encoding . UTF8 . GetBytes ( "updated" ) ; writeStream . Write ( updatedBytes , 0 , updatedBytes . Length ) ;
262262 writeStream . Flush ( ) ;
263263
264264 // Read-only stream should see updated content
265265 readStream . Position = 0 ;
266266 buffer = new byte [ 7 ] ;
267- bytesRead = readStream . Read ( buffer ) ;
267+ bytesRead = readStream . Read ( buffer , 0 , buffer . Length ) ;
268268 await That ( bytesRead ) . IsEqualTo ( 7 ) ;
269269 await That ( System . Text . Encoding . UTF8 . GetString ( buffer ) ) . IsEqualTo ( "updated" ) ;
270270 }
@@ -280,18 +280,18 @@ public async Task MockFileStream_SharedContent_WriteOnlyStreamShouldNotUnnecessa
280280
281281 // Read initial content
282282 var buffer = new byte [ 7 ] ;
283- var bytesRead = readStream . Read ( buffer ) ;
283+ var bytesRead = readStream . Read ( buffer , 0 , buffer . Length ) ;
284284 await That ( bytesRead ) . IsEqualTo ( 7 ) ;
285285
286286 // Write to write-only stream
287287 writeStream . Position = 0 ;
288- writeStream . Write ( System . Text . Encoding . UTF8 . GetBytes ( "changed" ) ) ;
288+ var changedBytes = System . Text . Encoding . UTF8 . GetBytes ( "changed" ) ; writeStream . Write ( changedBytes , 0 , changedBytes . Length ) ;
289289 writeStream . Flush ( ) ;
290290
291291 // Read stream should see the change
292292 readStream . Position = 0 ;
293293 buffer = new byte [ 7 ] ;
294- bytesRead = readStream . Read ( buffer ) ;
294+ bytesRead = readStream . Read ( buffer , 0 , buffer . Length ) ;
295295 await That ( bytesRead ) . IsEqualTo ( 7 ) ;
296296 await That ( System . Text . Encoding . UTF8 . GetString ( buffer ) ) . IsEqualTo ( "changed" ) ;
297297 }
@@ -308,26 +308,26 @@ public async Task MockFileStream_SharedContent_PartialReadsAndWrites()
308308 using var file2 = fileSystem . FileStream . New ( filename , FileMode . Open , FileAccess . ReadWrite , FileShare . ReadWrite ) ;
309309
310310 // Write data in chunks
311- file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 } ) ;
312- file1 . Write ( new byte [ ] { 5 , 6 , 7 , 8 } ) ;
311+ file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 } , 0 , 4 ) ;
312+ file1 . Write ( new byte [ ] { 5 , 6 , 7 , 8 } , 0 , 4 ) ;
313313 file1 . Flush ( ) ;
314314
315315 // Read data in different chunk sizes from file2
316316 var buffer = new byte [ 3 ] ;
317317
318318 // First partial read
319- var bytesRead1 = file2 . Read ( buffer ) ;
319+ var bytesRead1 = file2 . Read ( buffer , 0 , buffer . Length ) ;
320320 await That ( bytesRead1 ) . IsEqualTo ( 3 ) ;
321321 await That ( buffer ) . IsEquivalentTo ( new byte [ ] { 1 , 2 , 3 } ) ;
322322
323323 // Second partial read
324- var bytesRead2 = file2 . Read ( buffer ) ;
324+ var bytesRead2 = file2 . Read ( buffer , 0 , buffer . Length ) ;
325325 await That ( bytesRead2 ) . IsEqualTo ( 3 ) ;
326326 await That ( buffer ) . IsEquivalentTo ( new byte [ ] { 4 , 5 , 6 } ) ;
327327
328328 // Final partial read
329329 buffer = new byte [ 5 ] ;
330- var bytesRead3 = file2 . Read ( buffer ) ;
330+ var bytesRead3 = file2 . Read ( buffer , 0 , buffer . Length ) ;
331331 await That ( bytesRead3 ) . IsEqualTo ( 2 ) ;
332332 await That ( buffer . Take ( 2 ) . ToArray ( ) ) . IsEquivalentTo ( new byte [ ] { 7 , 8 } ) ;
333333 }
@@ -349,7 +349,7 @@ public async Task MockFileStream_SharedContent_FileLengthExtensionShouldBeVisibl
349349 using var file2 = fileSystem . FileStream . New ( filename , FileMode . Open , FileAccess . ReadWrite , FileShare . ReadWrite ) ;
350350
351351 // Write initial data
352- file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 } ) ;
352+ file1 . Write ( new byte [ ] { 1 , 2 , 3 , 4 } , 0 , 4 ) ;
353353 file1 . Flush ( ) ;
354354
355355 // Verify file2 sees initial length
@@ -358,15 +358,15 @@ public async Task MockFileStream_SharedContent_FileLengthExtensionShouldBeVisibl
358358 // Extend file via file1
359359 file1 . SetLength ( 10 ) ;
360360 file1 . Position = 8 ;
361- file1 . Write ( new byte [ ] { 9 , 10 } ) ;
361+ file1 . Write ( new byte [ ] { 9 , 10 } , 0 , 2 ) ;
362362 file1 . Flush ( ) ;
363363
364364 // file2 should see extended file
365365 await That ( file2 . Length ) . IsEqualTo ( 10 ) ;
366366
367367 file2 . Position = 8 ;
368368 var buffer = new byte [ 2 ] ;
369- var bytesRead = file2 . Read ( buffer ) ;
369+ var bytesRead = file2 . Read ( buffer , 0 , buffer . Length ) ;
370370 await That ( bytesRead ) . IsEqualTo ( 2 ) ;
371371 await That ( buffer ) . IsEquivalentTo ( new byte [ ] { 9 , 10 } ) ;
372372 }
@@ -389,14 +389,14 @@ public async Task MockFileStream_SharedContent_DisposedStreamsShouldNotAffectVer
389389 // Create and dispose a stream that writes data
390390 using ( var tempStream = fileSystem . FileStream . New ( filename , FileMode . Open , FileAccess . Write , FileShare . ReadWrite ) )
391391 {
392- tempStream . Write ( new byte [ ] { 1 , 2 , 3 , 4 } ) ;
392+ tempStream . Write ( new byte [ ] { 1 , 2 , 3 , 4 } , 0 , 4 ) ;
393393 tempStream . Flush ( ) ;
394394 } // tempStream is disposed here
395395
396396 // persistentStream should still see the data
397397 persistentStream . Position = 0 ;
398398 var buffer = new byte [ 4 ] ;
399- var bytesRead = persistentStream . Read ( buffer ) ;
399+ var bytesRead = persistentStream . Read ( buffer , 0 , buffer . Length ) ;
400400 await That ( bytesRead ) . IsEqualTo ( 4 ) ;
401401 await That ( buffer ) . IsEquivalentTo ( new byte [ ] { 1 , 2 , 3 , 4 } ) ;
402402 }
@@ -431,13 +431,13 @@ public async Task MockFileStream_SharedContent_LargeFile_ShouldPerformCorrectly(
431431 largeData [ cycle ] = ( byte ) ( cycle + 100 ) ;
432432
433433 file1 . Position = 0 ;
434- file1 . Write ( largeData ) ;
434+ file1 . Write ( largeData , 0 , largeData . Length ) ;
435435 file1 . Flush ( ) ;
436436
437437 // file2 should see the updated data
438438 file2 . Position = 0 ;
439439 var readData = new byte [ largeData . Length ] ;
440- var bytesRead = file2 . Read ( readData ) ;
440+ var bytesRead = file2 . Read ( readData , 0 , readData . Length ) ;
441441
442442 await That ( bytesRead ) . IsEqualTo ( largeData . Length ) ;
443443 await That ( readData ) . IsEquivalentTo ( largeData ) ;
0 commit comments