[corlib] Test FileInfo.MoveTo with files with same name
authorMarcos Henrich <marcos.henrich@xamarin.com>
Tue, 16 Feb 2016 10:34:08 +0000 (10:34 +0000)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Tue, 16 Feb 2016 10:34:08 +0000 (10:34 +0000)
Covers #18361

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

index 297a54bf74b853ee15086f6aa7de325687526cf7..0068c4643b8fdcae08e5070ee5ed340ab9d64cdf 100644 (file)
@@ -651,6 +651,33 @@ namespace MonoTests.System.IO
                        }
                }
 
+               [Test] //Covers #18361
+               public void MoveTo_SameName ()
+               {
+                       string name = "FIT.MoveTo.SameName.Test";
+                       string path1 = TempFolder + DSC + name;
+                       string path2 = name;
+                       DeleteFile (path1);
+                       DeleteFile (path2);
+                       
+                       try {
+                               File.Create (path1).Close ();
+                               FileInfo info1 = new FileInfo (path1);
+                               FileInfo info2 = new FileInfo (path2);
+                               Assert.IsTrue (info1.Exists, "#A1");
+                               Assert.IsFalse (info2.Exists, "#A2");
+
+                               info1.MoveTo (path2);
+                               info1 = new FileInfo (path1);
+                               info2 = new FileInfo (path2);
+                               Assert.IsFalse (info1.Exists, "#B1");
+                               Assert.IsTrue (info2.Exists, "#B2");
+                       } finally {
+                               DeleteFile (path1);
+                               DeleteFile (path2);
+                       }
+               }
+
                [Test]
                public void MoveTo_DestFileName_AlreadyExists ()
                {