@@ -423,65 +423,12 @@ public void DestinationFileIsTruncatedWhenItsLargerThanSourceFile()
423423 Assert . Equal ( content , File . ReadAllBytes ( destPath ) ) ;
424424 }
425425
426- [ Theory ]
427- [ InlineData ( " leading" , "destination" ) ]
428- [ InlineData ( "source" , " leading" ) ]
429- [ InlineData ( " leading" , " leadingdest" ) ]
430- public void CopyWithLeadingSpaces ( string sourceFileName , string destFileName )
431- {
432- DirectoryInfo testDir = Directory . CreateDirectory ( GetTestFilePath ( ) ) ;
433- string sourcePath = Path . Combine ( testDir . FullName , sourceFileName ) ;
434- string destPath = Path . Combine ( testDir . FullName , destFileName ) ;
435-
436- File . Create ( sourcePath ) . Dispose ( ) ;
437- Copy ( sourcePath , destPath ) ;
438-
439- Assert . True ( File . Exists ( sourcePath ) ) ;
440- Assert . True ( File . Exists ( destPath ) ) ;
441- }
442-
443- [ Theory ]
444- [ InlineData ( ".leading" , "destination" ) ]
445- [ InlineData ( "source" , ".leading" ) ]
446- public void CopyWithLeadingDots ( string sourceFileName , string destFileName )
447- {
448- DirectoryInfo testDir = Directory . CreateDirectory ( GetTestFilePath ( ) ) ;
449- string sourcePath = Path . Combine ( testDir . FullName , sourceFileName ) ;
450- string destPath = Path . Combine ( testDir . FullName , destFileName ) ;
451-
452- File . Create ( sourcePath ) . Dispose ( ) ;
453- Copy ( sourcePath , destPath ) ;
454-
455- Assert . True ( File . Exists ( sourcePath ) ) ;
456- Assert . True ( File . Exists ( destPath ) ) ;
457- }
458-
459- [ Theory ]
460- [ InlineData ( "-" , "destination" ) ]
461- [ InlineData ( "source" , "-" ) ]
462- [ InlineData ( "--" , "destination" ) ]
463- public void CopyWithDashPrefixedNames ( string sourceFileName , string destFileName )
464- {
465- DirectoryInfo testDir = Directory . CreateDirectory ( GetTestFilePath ( ) ) ;
466- string sourcePath = Path . Combine ( testDir . FullName , sourceFileName ) ;
467- string destPath = Path . Combine ( testDir . FullName , destFileName ) ;
468-
469- File . Create ( sourcePath ) . Dispose ( ) ;
470- Copy ( sourcePath , destPath ) ;
471-
472- Assert . True ( File . Exists ( sourcePath ) ) ;
473- Assert . True ( File . Exists ( destPath ) ) ;
474- }
475-
476- [ Theory ]
477- [ InlineData ( "file\t name" , "destination" ) ]
478- [ InlineData ( "source" , "file\t name" ) ]
479- [ PlatformSpecific ( TestPlatforms . AnyUnix ) ]
480- public void UnixCopyWithEmbeddedControlCharacters ( string sourceFileName , string destFileName )
426+ [ Theory , MemberData ( nameof ( TestData . ValidFileNames ) , MemberType = typeof ( TestData ) ) ]
427+ public void CopyWithProblematicNames ( string fileName )
481428 {
482429 DirectoryInfo testDir = Directory . CreateDirectory ( GetTestFilePath ( ) ) ;
483- string sourcePath = Path . Combine ( testDir . FullName , sourceFileName ) ;
484- string destPath = Path . Combine ( testDir . FullName , destFileName ) ;
430+ string sourcePath = Path . Combine ( testDir . FullName , fileName ) ;
431+ string destPath = Path . Combine ( testDir . FullName , fileName + "_copy" ) ;
485432
486433 File . Create ( sourcePath ) . Dispose ( ) ;
487434 Copy ( sourcePath , destPath ) ;
@@ -502,8 +449,8 @@ public void WindowsCopyWithTrailingSpacePeriod_ViaExtendedSyntax(string sourceFi
502449 // because path normalization strips these characters. While enumeration APIs like
503450 // Directory.GetFiles can discover these files, direct string-based APIs (File.OpenRead,
504451 // File.Exists) will fail because the trailing characters get stripped during normalization.
505- // Only FileInfo/DirectoryInfo objects from enumeration use EnsureExtendedPrefixIfNeeded
506- // internally and can access these files . See TrimmedPaths.cs for comprehensive tests.
452+ // FileInfo/DirectoryInfo objects from enumeration work because they skip path normalization
453+ // and use the original path directly . See TrimmedPaths.cs for comprehensive tests.
507454 DirectoryInfo testDir = Directory . CreateDirectory ( GetTestFilePath ( ) ) ;
508455 string sourcePath = Path . Combine ( testDir . FullName , sourceFileName ) ;
509456 string destPath = Path . Combine ( testDir . FullName , destFileName ) ;
@@ -521,22 +468,6 @@ public void WindowsCopyWithTrailingSpacePeriod_ViaExtendedSyntax(string sourceFi
521468 Assert . True ( File . Exists ( sourceToCopy ) ) ;
522469 Assert . True ( File . Exists ( destToCopy ) ) ;
523470 }
524-
525- [ Theory ]
526- [ InlineData ( "name with spaces" , "dest with spaces" ) ]
527- [ InlineData ( "name.with.periods" , "dest.with.periods" ) ]
528- public void CopyEmbeddedSpacesPeriods ( string sourceFileName , string destFileName )
529- {
530- DirectoryInfo testDir = Directory . CreateDirectory ( GetTestFilePath ( ) ) ;
531- string sourcePath = Path . Combine ( testDir . FullName , sourceFileName ) ;
532- string destPath = Path . Combine ( testDir . FullName , destFileName ) ;
533-
534- File . Create ( sourcePath ) . Dispose ( ) ;
535- Copy ( sourcePath , destPath ) ;
536-
537- Assert . True ( File . Exists ( sourcePath ) ) ;
538- Assert . True ( File . Exists ( destPath ) ) ;
539- }
540471 }
541472
542473 /// <summary>
0 commit comments