@@ -10,7 +10,7 @@ public class Directory_Exists : FileSystemTest
1010 {
1111 #region Utilities
1212
13- public bool Exists ( string path )
13+ public virtual bool Exists ( string path )
1414 {
1515 return Directory . Exists ( path ) ;
1616 }
@@ -57,17 +57,6 @@ public void PathWithInvalidCharactersAsPath_ReturnsFalse(string invalidPath)
5757 Assert . False ( Exists ( TestDirectory + Path . DirectorySeparatorChar + invalidPath ) ) ;
5858 }
5959
60- [ Fact ]
61- public void PathAlreadyExistsAsFile ( )
62- {
63- string path = GetTestFilePath ( ) ;
64- File . Create ( path ) . Dispose ( ) ;
65-
66- Assert . False ( Exists ( IOServices . RemoveTrailingSlash ( path ) ) ) ;
67- Assert . False ( Exists ( IOServices . RemoveTrailingSlash ( IOServices . RemoveTrailingSlash ( path ) ) ) ) ;
68- Assert . False ( Exists ( IOServices . RemoveTrailingSlash ( IOServices . AddTrailingSlashIfNeeded ( path ) ) ) ) ;
69- }
70-
7160 [ Fact ]
7261 public void PathAlreadyExistsAsDirectory ( )
7362 {
@@ -180,18 +169,6 @@ public void ValidExtendedPathExists_ReturnsTrue(string component)
180169 Assert . True ( Exists ( path ) ) ;
181170 }
182171
183- [ ConditionalFact ( nameof ( UsingNewNormalization ) ) ]
184- [ PlatformSpecific ( TestPlatforms . Windows ) ] // Extended path already exists as file
185- public void ExtendedPathAlreadyExistsAsFile ( )
186- {
187- string path = IOInputs . ExtendedPrefix + GetTestFilePath ( ) ;
188- File . Create ( path ) . Dispose ( ) ;
189-
190- Assert . False ( Exists ( IOServices . RemoveTrailingSlash ( path ) ) ) ;
191- Assert . False ( Exists ( IOServices . RemoveTrailingSlash ( IOServices . RemoveTrailingSlash ( path ) ) ) ) ;
192- Assert . False ( Exists ( IOServices . RemoveTrailingSlash ( IOServices . AddTrailingSlashIfNeeded ( path ) ) ) ) ;
193- }
194-
195172 [ ConditionalFact ( nameof ( UsingNewNormalization ) ) ]
196173 [ PlatformSpecific ( TestPlatforms . Windows ) ] // Extended path already exists as directory
197174 public void ExtendedPathAlreadyExistsAsDirectory ( )
@@ -387,6 +364,34 @@ public void SubdirectoryOnNonExistentDriveAsPath_ReturnsFalse()
387364 Assert . False ( Exists ( Path . Combine ( IOServices . GetNonExistentDrive ( ) , "nonexistentsubdir" ) ) ) ;
388365 }
389366
367+ #endregion
368+ }
369+
370+ public class Directory_ExistsAsFile : FileSystemTest
371+ {
372+ [ Fact ]
373+ public void PathAlreadyExistsAsFile ( )
374+ {
375+ string path = GetTestFilePath ( ) ;
376+ File . Create ( path ) . Dispose ( ) ;
377+
378+ Assert . False ( Directory . Exists ( IOServices . RemoveTrailingSlash ( path ) ) ) ;
379+ Assert . False ( Directory . Exists ( IOServices . RemoveTrailingSlash ( IOServices . RemoveTrailingSlash ( path ) ) ) ) ;
380+ Assert . False ( Directory . Exists ( IOServices . RemoveTrailingSlash ( IOServices . AddTrailingSlashIfNeeded ( path ) ) ) ) ;
381+ }
382+
383+ [ ConditionalFact ( nameof ( UsingNewNormalization ) ) ]
384+ [ PlatformSpecific ( TestPlatforms . Windows ) ] // Extended path already exists as file
385+ public void ExtendedPathAlreadyExistsAsFile ( )
386+ {
387+ string path = IOInputs . ExtendedPrefix + GetTestFilePath ( ) ;
388+ File . Create ( path ) . Dispose ( ) ;
389+
390+ Assert . False ( Directory . Exists ( IOServices . RemoveTrailingSlash ( path ) ) ) ;
391+ Assert . False ( Directory . Exists ( IOServices . RemoveTrailingSlash ( IOServices . RemoveTrailingSlash ( path ) ) ) ) ;
392+ Assert . False ( Directory . Exists ( IOServices . RemoveTrailingSlash ( IOServices . AddTrailingSlashIfNeeded ( path ) ) ) ) ;
393+ }
394+
390395 [ Fact ]
391396 [ PlatformSpecific ( TestPlatforms . AnyUnix & ~ TestPlatforms . Browser ) ] // Makes call to native code (libc)
392397 public void FalseForNonRegularFile ( )
@@ -395,7 +400,5 @@ public void FalseForNonRegularFile()
395400 Assert . Equal ( 0 , mkfifo ( fileName , 0 ) ) ;
396401 Assert . False ( Directory . Exists ( fileName ) ) ;
397402 }
398-
399- #endregion
400403 }
401404}
0 commit comments