Skip to content

Commit 99b2fd7

Browse files
committed
feat: refactored the logic
1 parent 402f597 commit 99b2fd7

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ public override void Move(string sourceDirName, string destDirName)
503503
var fullSourcePath = mockFileDataAccessor.Path.GetFullPath(sourceDirName).TrimSlashes();
504504
var fullDestPath = mockFileDataAccessor.Path.GetFullPath(destDirName).TrimSlashes();
505505

506-
if (XFS.IsUnixPlatform() ? mockFileDataAccessor.StringOperations.Equals(fullSourcePath, fullDestPath)
507-
: string.Equals(fullSourcePath, fullDestPath, StringComparison.Ordinal))
506+
if (string.Equals(fullSourcePath, fullDestPath, StringComparison.Ordinal))
508507
{
509508
throw new IOException("Source and destination path must be different.");
510509
}
@@ -535,17 +534,12 @@ public override void Move(string sourceDirName, string destDirName)
535534
{
536535
throw CommonExceptions.CouldNotFindPartOfPath(destDirName);
537536
}
538-
if (XFS.IsUnixPlatform())
539-
{
540-
if (mockFileDataAccessor.Directory.Exists(fullDestPath) || mockFileDataAccessor.File.Exists(fullDestPath))
541-
{
542-
throw CommonExceptions.CannotCreateBecauseSameNameAlreadyExists(fullDestPath);
543-
}
544-
}
545-
else if (!string.Equals(fullSourcePath, fullDestPath, StringComparison.OrdinalIgnoreCase))
537+
538+
if (mockFileDataAccessor.Directory.Exists(fullDestPath) || mockFileDataAccessor.File.Exists(fullDestPath))
546539
{
547540
// In Windows, file/dir names are case sensetive, C:\\temp\\src and C:\\temp\\SRC and treated different
548-
if (mockFileDataAccessor.Directory.Exists(fullDestPath) || mockFileDataAccessor.File.Exists(fullDestPath))
541+
if (XFS.IsUnixPlatform() ||
542+
!string.Equals(fullSourcePath, fullDestPath, StringComparison.OrdinalIgnoreCase))
549543
{
550544
throw CommonExceptions.CannotCreateBecauseSameNameAlreadyExists(fullDestPath);
551545
}

0 commit comments

Comments
 (0)