@@ -1903,5 +1903,69 @@ public void MockDirectory_SetCreationTime_ShouldNotThrowWithoutTrailingBackslash
19031903 fs . Directory . SetCreationTime ( path , DateTime . Now ) ;
19041904 fs . Directory . Delete ( path ) ;
19051905 }
1906+
1907+ [ Test ]
1908+ [ TestCase ( @"c:\temp2\fd\df" ) ]
1909+ [ TestCase ( @"c:\temp2\fd\" ) ]
1910+ [ TestCase ( @"c:\temp2\fd\..\fd" ) ]
1911+ [ TestCase ( @"c:\temp2\fd" ) ]
1912+ [ TestCase ( @".\..\temp2\fd\df" ) ]
1913+ [ TestCase ( @".\..\temp2\fd\df\.." ) ]
1914+ [ TestCase ( @".\..\temp2\fd\df\..\" ) ]
1915+ [ TestCase ( @"..\temp2\fd\" ) ]
1916+ [ TestCase ( @".\temp2\fd" ) ]
1917+ [ TestCase ( @"\temp2\fd" ) ]
1918+ [ TestCase ( @"temp2\fd" ) ]
1919+ public void Move_Directory_Throws_When_Target_Directory_Without_First_Order_Path_Is_Missing (
1920+ string targetDirName )
1921+ {
1922+ // Arange
1923+ var fileSystem = new MockFileSystem ( new Dictionary < string , MockFileData >
1924+ {
1925+ { XFS . Path ( @"c:\temp\exists\foldertomove" ) , new MockDirectoryData ( ) }
1926+ } ) ;
1927+
1928+ string folderToMove = XFS . Path ( @"c:\temp\exists\foldertomove" ) ;
1929+ targetDirName = XFS . Path ( targetDirName ) ;
1930+
1931+ // Act
1932+ Assert . Throws < DirectoryNotFoundException > ( ( ) =>
1933+ fileSystem . Directory . Move ( folderToMove , targetDirName ) ) ;
1934+
1935+ // Assert
1936+ Assert . IsFalse ( fileSystem . Directory . Exists ( targetDirName ) ) ;
1937+ }
1938+
1939+ [ Test ]
1940+ [ TestCase ( @"c:\temp2\" ) ]
1941+ [ TestCase ( @"c:\temp2" ) ]
1942+ [ TestCase ( @"c:\temp2\..\temp2" ) ]
1943+ [ TestCase ( @".\..\temp2" ) ]
1944+ [ TestCase ( @".\..\temp2\..\temp2" ) ]
1945+ [ TestCase ( @".\..\temp2\fd\df\..\.." ) ]
1946+ [ TestCase ( @".\..\temp2\fd\df\..\..\" ) ]
1947+ [ TestCase ( @"..\temp2" ) ]
1948+ [ TestCase ( @".\temp2" ) ]
1949+ [ TestCase ( @"\temp2" ) ]
1950+ [ TestCase ( @"temp2" ) ]
1951+ public void Move_Directory_DoesNotThrow_When_Target_Directory_With_First_Order_Path_Is_Missing (
1952+ string targetDirName )
1953+ {
1954+ // Arange
1955+ var fileSystem = new MockFileSystem ( new Dictionary < string , MockFileData >
1956+ {
1957+ { XFS . Path ( @"c:\temp\exists\foldertomove" ) , new MockDirectoryData ( ) }
1958+ } ) ;
1959+
1960+ string folderToMove = XFS . Path ( @"c:\temp\exists\foldertomove" ) ;
1961+ targetDirName = XFS . Path ( targetDirName ) ;
1962+
1963+ // Act
1964+ Assert . DoesNotThrow ( ( ) =>
1965+ fileSystem . Directory . Move ( folderToMove , targetDirName ) ) ;
1966+
1967+ // Assert
1968+ Assert . IsTrue ( fileSystem . Directory . Exists ( targetDirName ) ) ;
1969+ }
19061970 }
19071971}
0 commit comments