@@ -503,7 +503,8 @@ 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 ( mockFileDataAccessor . StringOperations . Equals ( fullSourcePath , fullDestPath ) )
506+ if ( XFS . IsUnixPlatform ( ) ? mockFileDataAccessor . StringOperations . Equals ( fullSourcePath , fullDestPath )
507+ : mockFileDataAccessor . StringOperations . Equals ( fullSourcePath , fullDestPath , StringComparison . Ordinal ) )
507508 {
508509 throw new IOException ( "Source and destination path must be different." ) ;
509510 }
@@ -534,12 +535,21 @@ public override void Move(string sourceDirName, string destDirName)
534535 {
535536 throw CommonExceptions . CouldNotFindPartOfPath ( destDirName ) ;
536537 }
537-
538- if ( mockFileDataAccessor . Directory . Exists ( fullDestPath ) || mockFileDataAccessor . File . Exists ( fullDestPath ) )
538+ if ( XFS . IsUnixPlatform ( ) )
539539 {
540- throw CommonExceptions . CannotCreateBecauseSameNameAlreadyExists ( fullDestPath ) ;
540+ if ( mockFileDataAccessor . Directory . Exists ( fullDestPath ) || mockFileDataAccessor . File . Exists ( fullDestPath ) )
541+ {
542+ throw CommonExceptions . CannotCreateBecauseSameNameAlreadyExists ( fullDestPath ) ;
543+ }
544+ }
545+ else if ( ! mockFileDataAccessor . StringOperations . Equals ( fullSourcePath , fullDestPath , StringComparison . OrdinalIgnoreCase ) )
546+ {
547+ // In Windows, file/dir names are case case sensetive, src and SRC and treated different
548+ if ( mockFileDataAccessor . Directory . Exists ( fullDestPath ) || mockFileDataAccessor . File . Exists ( fullDestPath ) )
549+ {
550+ throw CommonExceptions . CannotCreateBecauseSameNameAlreadyExists ( fullDestPath ) ;
551+ }
541552 }
542-
543553 mockFileDataAccessor . MoveDirectory ( fullSourcePath , fullDestPath ) ;
544554 }
545555
@@ -653,15 +663,15 @@ public override IEnumerable<string> EnumerateDirectories(string path, string sea
653663 . Where ( p => ! mockFileDataAccessor . StringOperations . Equals ( p , path ) )
654664 . Select ( p => FixPrefix ( p , originalPath ) ) ;
655665 }
656-
666+
657667 private string FixPrefix ( string path , string originalPath )
658668 {
659669 var normalizedOriginalPath = mockFileDataAccessor . Path . GetFullPath ( originalPath ) ;
660670 var pathWithoutOriginalPath = path . Substring ( normalizedOriginalPath . Length )
661671 . TrimStart ( mockFileDataAccessor . Path . DirectorySeparatorChar ) ;
662672 return mockFileDataAccessor . Path . Combine ( originalPath , pathWithoutOriginalPath ) ;
663673 }
664-
674+
665675#if FEATURE_ENUMERATION_OPTIONS
666676 /// <inheritdoc />
667677 public override IEnumerable < string > EnumerateDirectories ( string path , string searchPattern , EnumerationOptions enumerationOptions )
0 commit comments