[corlib] Test FileStream with Read and Writes
authorMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 25 Feb 2016 18:38:05 +0000 (18:38 +0000)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 25 Feb 2016 18:38:05 +0000 (18:38 +0000)
Covers #11699

mcs/class/corlib/Test/System.IO/FileStreamTest.cs

index 2eae58e3e444e17fdc8447ccaee689a3aa6605bf..84a9d638ed6bed978c8f2595ae5e2fd0b9328c4d 100644 (file)
@@ -1725,5 +1725,30 @@ namespace MonoTests.System.IO
                        }
                }
 #endif
+
+               [Test] // Covers #11699
+               public void ReadWriteFileLength ()
+               {
+                       int bufferSize = 128;
+                       int readLength = 1;
+                       int writeLength = bufferSize + 1;
+
+                       string path = TempFolder + DSC + "readwritefilelength.tmp";
+
+                       try {
+                               File.WriteAllBytes (path, new byte [readLength + 1]);
+
+                               using (var file = new FileStream (path, FileMode.Open, FileAccess.ReadWrite, FileShare.Read,
+                                                                                                bufferSize, FileOptions.SequentialScan))
+                               {
+                                       file.Read (new byte [readLength], 0, readLength);
+                                       file.Write (new byte [writeLength], 0, writeLength);
+
+                                       Assert.AreEqual (readLength + writeLength, file.Length);
+                               }
+                       } finally {
+                               DeleteFile (path);
+                       }
+               }
        }
 }