File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
src/TestableIO.System.IO.Abstractions.TestingHelpers
tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ public override string GetFullPath(string path)
8585 // unc paths need at least two segments, the others need one segment
8686 var isUnixRooted = mockFileDataAccessor . StringOperations . StartsWith (
8787 mockFileDataAccessor . Directory . GetCurrentDirectory ( ) ,
88- string . Format ( CultureInfo . InvariantCulture , "{0}" , DirectorySeparatorChar ) ) ;
88+ "/" ) ;
8989
9090 var minPathSegments = isUnc
9191 ? 2
@@ -121,7 +121,7 @@ public override string GetFullPath(string path)
121121
122122 if ( isUnixRooted && ! isUnc )
123123 {
124- fullPath = DirectorySeparatorChar + fullPath ;
124+ fullPath = "/" + fullPath ;
125125 }
126126 else if ( isUnixRooted )
127127 {
@@ -156,4 +156,4 @@ public override string GetTempFileName()
156156 /// <inheritdoc />
157157 public override string GetTempPath ( ) => defaultTempDirectory ;
158158 }
159- }
159+ }
Original file line number Diff line number Diff line change @@ -96,7 +96,28 @@ public void MockDirectoryInfo_GetFiles_ShouldWorkWithUNCPath()
9696 Assert . AreEqual ( fileName , files [ 0 ] . FullName ) ;
9797 }
9898
99+ [ Test ]
100+ [ WindowsOnly ( WindowsSpecifics . UNCPaths ) ]
101+ public void MockDirectoryInfo_GetFiles_ShouldWorkWithUNCPath_WhenCurrentDirectoryIsUnc ( )
102+ {
103+ var fileName = XFS . Path ( @"\\unc\folder\file.txt" ) ;
104+ var directoryName = XFS . Path ( @"\\unc\folder" ) ;
105+ // Arrange
106+ var fileSystem = new MockFileSystem ( new Dictionary < string , MockFileData >
107+ {
108+ { fileName , "" }
109+ } ) ;
110+
111+ fileSystem . Directory . SetCurrentDirectory ( directoryName ) ;
112+
113+ var directoryInfo = new MockDirectoryInfo ( fileSystem , directoryName ) ;
114+
115+ // Act
116+ var files = directoryInfo . GetFiles ( ) ;
99117
118+ // Assert
119+ Assert . AreEqual ( fileName , files [ 0 ] . FullName ) ;
120+ }
100121
101122 [ Test ]
102123 public void MockDirectoryInfo_FullName_ShouldReturnFullNameWithoutIncludingTrailingPathDelimiter ( )
You can’t perform that action at this time.
0 commit comments