Skip to content

Commit d843e9d

Browse files
committed
test: added the test, removed two outdated tests
1 parent bd19fcd commit d843e9d

File tree

1 file changed

+16
-33
lines changed

1 file changed

+16
-33
lines changed

tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,21 +1811,6 @@ public async Task MockDirectory_GetParent_ShouldReturnTheParentWithoutTrailingDi
18111811
await That(actualResult.FullName).IsEqualTo(expectedResult);
18121812
}
18131813

1814-
[Test]
1815-
public async Task MockDirectory_Move_ShouldThrowAnIOExceptionIfBothPathAreIdentical()
1816-
{
1817-
// Arrange
1818-
string path = XFS.Path(@"c:\a");
1819-
var fileSystem = new MockFileSystem();
1820-
fileSystem.AddDirectory(path);
1821-
1822-
// Act
1823-
Action action = () => fileSystem.Directory.Move(path, path);
1824-
1825-
// Assert
1826-
await That(action, "Source and destination path must be different.").Throws<IOException>();
1827-
}
1828-
18291814
[Test]
18301815
[WindowsOnly(WindowsSpecifics.Drives)]
18311816
public async Task MockDirectory_Move_ShouldThrowAnIOExceptionIfDirectoriesAreOnDifferentVolumes()
@@ -1857,24 +1842,7 @@ public async Task MockDirectory_Move_ShouldThrowADirectoryNotFoundExceptionIfDes
18571842
// Assert
18581843
await That(action, "Could not find a part of the path 'c:\a'.").Throws<DirectoryNotFoundException>();
18591844
}
1860-
1861-
[Test]
1862-
public async Task MockDirectory_Move_ShouldThrowAnIOExceptionIfDestinationDirectoryExists()
1863-
{
1864-
// Arrange
1865-
string sourcePath = XFS.Path(@"c:\a");
1866-
string destPath = XFS.Path(@"c:\b");
1867-
var fileSystem = new MockFileSystem();
1868-
fileSystem.AddDirectory(sourcePath);
1869-
fileSystem.AddDirectory(destPath);
1870-
1871-
// Act
1872-
Action action = () => fileSystem.Directory.Move(sourcePath, destPath);
1873-
1874-
// Assert
1875-
await That(action, "Cannot create 'c:\b\' because a file or directory with the same name already exists.'").Throws<IOException>();
1876-
}
1877-
1845+
18781846
[Test]
18791847
public async Task MockDirectory_EnumerateFiles_ShouldReturnAllFilesBelowPathWhenPatternIsWildcardAndSearchOptionIsAllDirectories()
18801848
{
@@ -2204,4 +2172,19 @@ public async Task MockDirectory_Exists_ShouldReturnTrue_IfArgIsFrontSlashAndRoot
22042172

22052173
await That(fileSystem.Directory.Exists("/")).IsEqualTo(true);
22062174
}
2175+
2176+
[Test]
2177+
public async Task MockDirectory_Move_ShoudlNotThrowException_When_SourceAndDestLocationAreSame()
2178+
{
2179+
// Arrange
2180+
MockFileSystem mockFs = new MockFileSystem();
2181+
string tempDir = mockFs.Path.GetTempPath();
2182+
string src = mockFs.Path.Combine(tempDir, "src");
2183+
string dest = mockFs.Path.Combine(tempDir, "src");
2184+
IDirectoryInfo srcDir = mockFs.DirectoryInfo.New(src);
2185+
srcDir.Create();
2186+
2187+
// Act & Assert
2188+
await That(() => mockFs.Directory.Move(src, dest)).DoesNotThrow();
2189+
}
22072190
}

0 commit comments

Comments
 (0)