1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Xunit; 6 7 namespace System.IO.Tests 8 { 9 public class DirectoryInfo_MoveTo : Directory_Move 10 { 11 #region Utilities 12 Move(string sourceDir, string destDir)13 public override void Move(string sourceDir, string destDir) 14 { 15 new DirectoryInfo(sourceDir).MoveTo(destDir); 16 } 17 Move(DirectoryInfo sourceDir, string destDir)18 public virtual void Move(DirectoryInfo sourceDir, string destDir) 19 { 20 sourceDir.MoveTo(destDir); 21 } 22 23 #endregion 24 25 #region UniversalTests 26 27 [Fact] DirectoryPathUpdatesOnMove()28 public void DirectoryPathUpdatesOnMove() 29 { 30 //NOTE: MoveTo adds a trailing separator character to the FullName of a DirectoryInfo 31 string testDirSource = Path.Combine(TestDirectory, GetTestFileName()); 32 string testDirDest1 = Path.Combine(TestDirectory, GetTestFileName()); 33 string testDirDest2 = Path.Combine(TestDirectory, GetTestFileName()); 34 35 DirectoryInfo sourceDir = Directory.CreateDirectory(testDirSource); 36 Move(sourceDir, testDirDest1); 37 Assert.True(Directory.Exists(testDirDest1)); 38 Assert.False(Directory.Exists(testDirSource)); 39 Assert.Equal(testDirDest1 + Path.DirectorySeparatorChar, sourceDir.FullName); 40 41 Move(sourceDir, testDirDest2); 42 Assert.True(Directory.Exists(testDirDest2)); 43 Assert.Equal(testDirDest2 + Path.DirectorySeparatorChar, sourceDir.FullName); 44 } 45 46 #endregion 47 } 48 } 49