Add a more functional (i.e. fewer-stubs) implementation of System.Data.Linq.
[mono.git] / mcs / class / corlib / Test / System.IO / FileStreamTest.cs
index 16d9196ec231b1a0c17a2c47eb351fbb59a21c96..9324c911f4d6acd16d9cfa5ac95e76b489987765 100644 (file)
@@ -712,6 +712,7 @@ namespace MonoTests.System.IO
                }
 #endif // TARGET_JVM
 
+               [Category("TargetJvmNotSupported")] // File sharing not supported for TARGET_JVM
                [Test, ExpectedException (typeof (IOException))]
                public void CtorIOException ()
                {
@@ -759,41 +760,49 @@ namespace MonoTests.System.IO
                }
 
                [Test]
+               [Category("TargetJvmNotSupported")] // File sharing not supported for TARGET_JVM
                [ExpectedException (typeof (IOException))]
                public void CtorAccess1Read2Write ()
                {
                        string fn = Path.Combine (TempFolder, "temp");
-                       FileStream fs = null;
+                       FileStream fs1 = null;
+                       FileStream fs2 = null;
                        try {
                                if (!File.Exists (fn)) {
                                        using (TextWriter tw = File.CreateText (fn)) {
                                                tw.Write ("FOO");
                                        }
                                }
-                               fs = new FileStream (fn, FileMode.Open, FileAccess.Read);
-                               fs = new FileStream (fn, FileMode.Create, FileAccess.Write);
+                               fs1 = new FileStream (fn, FileMode.Open, FileAccess.Read);
+                               fs2 = new FileStream (fn, FileMode.Create, FileAccess.Write);
                        } finally {
-                               if (fs != null)
-                                       fs.Close ();
+                               if (fs1 != null)
+                                       fs1.Close ();
+                               if (fs2 != null)
+                                       fs2.Close ();
                                if (File.Exists (fn))
                                        File.Delete (fn);
                        }
                }
 
                [Test]
+               [Category("TargetJvmNotSupported")] // File sharing not supported for TARGET_JVM
                [ExpectedException (typeof (IOException))]
                public void CtorAccess1Write2Write ()
                {
                        string fn = Path.Combine (TempFolder, "temp");
-                       FileStream fs = null;
+                       FileStream fs1 = null;
+                       FileStream fs2 = null;
                        try {
                                if (File.Exists (fn))
                                        File.Delete (fn);
-                               fs = new FileStream (fn, FileMode.Create, FileAccess.Write);
-                               fs = new FileStream (fn, FileMode.Create, FileAccess.Write);
+                               fs1 = new FileStream (fn, FileMode.Create, FileAccess.Write);
+                               fs2 = new FileStream (fn, FileMode.Create, FileAccess.Write);
                        } finally {
-                               if (fs != null)
-                                       fs.Close ();
+                               if (fs1 != null)
+                                       fs1.Close ();
+                               if (fs2 != null)
+                                       fs2.Close ();
                                if (File.Exists (fn))
                                        File.Delete (fn);
                        }
@@ -812,6 +821,39 @@ namespace MonoTests.System.IO
                        }
                }
 
+#if NET_2_0
+               [Test] // bug #79250
+               public void FileShare_Delete ()
+               {
+                       string fn = Path.Combine (TempFolder, "temp");
+                       
+                       using (Stream s = new FileStream (fn, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Delete)) {
+                               s.Write (new byte [1] { 0x5 }, 0, 1);
+                               File.Delete (fn);
+                       }
+
+                       using (Stream s = new FileStream (fn, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete)) {
+                               s.Write (new byte [1] { 0x5 }, 0, 1);
+                               File.Delete (fn);
+                       }
+
+                       using (Stream s = new FileStream (fn, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write | FileShare.Delete)) {
+                               s.Write (new byte [1] { 0x5 }, 0, 1);
+                               File.Delete (fn);
+                       }
+
+                       using (Stream s = new FileStream (fn, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read | FileShare.Delete)) {
+                               s.Write (new byte [1] { 0x5 }, 0, 1);
+                               File.Delete (fn);
+                       }
+
+                       using (Stream s = new FileStream (fn, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Inheritable | FileShare.Delete)) {
+                               s.Write (new byte [1] { 0x5 }, 0, 1);
+                               File.Delete (fn);
+                       }
+               }
+#endif
+
                [Test]
                public void Write ()
                {
@@ -974,6 +1016,7 @@ namespace MonoTests.System.IO
                        DeleteFile (path);
                }
 
+               [Category("TargetJvmNotSupported")] // File locking not supported for TARGET_JVM
                public void TestLock ()
                {
                        string path = TempFolder + Path.DirectorySeparatorChar + "TestLock";
@@ -1444,6 +1487,7 @@ namespace MonoTests.System.IO
                }
 
                [Test]
+               [Category("TargetJvmNotSupported")] // Async IO not supported for TARGET_JVM
                [ExpectedException (typeof (ObjectDisposedException))]
                public void BeginRead_Disposed ()
                {
@@ -1455,6 +1499,7 @@ namespace MonoTests.System.IO
                }
 
                [Test]
+               [Category("TargetJvmNotSupported")] // Async IO not supported for TARGET_JVM
                [ExpectedException (typeof (ObjectDisposedException))]
                public void BeginWrite_Disposed ()
                {
@@ -1466,6 +1511,7 @@ namespace MonoTests.System.IO
                }
 
                [Test]
+               [Category("TargetJvmNotSupported")] // File locking not supported for TARGET_JVM
                [ExpectedException (typeof (ObjectDisposedException))]
                public void Lock_Disposed ()
                {
@@ -1477,6 +1523,7 @@ namespace MonoTests.System.IO
                }
 
                [Test]
+               [Category("TargetJvmNotSupported")] // File locking not supported for TARGET_JVM
                [ExpectedException (typeof (ObjectDisposedException))]
                public void Unlock_Disposed ()
                {
@@ -1540,7 +1587,9 @@ namespace MonoTests.System.IO
                }
 
 #if NET_2_0
-               [Test] public void DeleteOnClose ()
+               [Category("TargetJvmNotSupported")] // FileOptions.DeleteOnClose not supported for TARGET_JVM
+               [Test]
+               public void DeleteOnClose ()
                {
                        string path = TempFolder + DSC + "created.txt";
                        DeleteFile (path);
@@ -1554,4 +1603,3 @@ namespace MonoTests.System.IO
 #endif
        }
 }
-