2009-12-01 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Tue, 1 Dec 2009 06:35:39 +0000 (06:35 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Tue, 1 Dec 2009 06:35:39 +0000 (06:35 -0000)
* FileTest.cs: New test for File.Copy throwing an exception if src and
dest are the same.

svn path=/trunk/mcs/; revision=147180

mcs/class/corlib/Test/System.IO/ChangeLog
mcs/class/corlib/Test/System.IO/FileTest.cs

index 9c17a4a30e426302c4f47f709d590ce711ce0062..8cad846ac07e20c1bc9c4934539607c008f20ee6 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-01  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * FileTest.cs: New test for File.Copy throwing an exception if src and
+       dest are the same.
+
 2009-10-15  Sebastien Pouliot  <sebastien@ximian.com>
 
        * UnmanagedMemoryStreamTest.cs: Add more test cases to cover all
index 172a0ace5224f2b526794b7343d7181150ce2f17..f89daed1db0f8d577d588369faa07c7846667afd 100644 (file)
@@ -342,6 +342,27 @@ namespace MonoTests.System.IO
                        }
                }
 
+               [Test]
+               public void Copy_SourceFileName_DestFileName_Same ()
+               {
+                       string source = TempFolder + Path.DirectorySeparatorChar + "SameFile.txt";
+                       DeleteFile (source);
+                       try {
+                               // new empty file
+                               File.Create (source).Close ();
+                               try {
+                                       File.Copy (source, source, true);
+                                       Assert.Fail ("#1");
+                               } catch (IOException ex) {
+                                       // process cannot access file ... because it is being used by another process
+                                       Assert.IsNull (ex.InnerException, "#2");
+                                       Assert.IsTrue (ex.Message.IndexOf (source) != -1, "#3");
+                               }
+                       } finally {
+                               DeleteFile (source);
+                       }
+               }
+
                [Test]
                public void Copy ()
                {