File tree Expand file tree Collapse file tree
System.IO.Abstractions.TestingHelpers.Tests
System.IO.Abstractions.TestingHelpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -788,6 +788,20 @@ public void MockDirectory_GetFiles_Returns_Files()
788788 Assert . AreEqual ( testPath , entries . First ( ) ) ;
789789 }
790790
791+ [ Test ]
792+ public void MockDirectory_GetFiles_Returns_Files_WithRelativePath ( )
793+ {
794+ // arrange
795+ var fileSystem = new MockFileSystem ( new Dictionary < string , MockFileData > ( ) ) ;
796+
797+ string directory = XFS . Path ( @"C:\foo" ) ;
798+
799+ fileSystem . Directory . SetCurrentDirectory ( directory ) ;
800+ fileSystem . AddFile ( XFS . Path ( @"C:\test.txt" ) , new MockFileData ( "Some ASCII text." ) ) ;
801+
802+ Assert . AreEqual ( fileSystem . Directory . GetFiles ( XFS . Path ( @"..\" ) ) . Length , 1 ) ; // Assert with relative path
803+ }
804+
791805 [ Test ]
792806 public void MockDirectory_GetFiles_ShouldThrowAnArgumentNullException_IfSearchPatternIsNull ( )
793807 {
Original file line number Diff line number Diff line change @@ -212,14 +212,13 @@ private string[] GetFilesInternal(
212212 CheckSearchPattern ( searchPattern ) ;
213213 path = path . TrimSlashes ( ) ;
214214 path = path . NormalizeSlashes ( ) ;
215+ path = mockFileDataAccessor . Path . GetFullPath ( path ) ;
215216
216217 if ( ! Exists ( path ) )
217218 {
218219 throw CommonExceptions . CouldNotFindPartOfPath ( path ) ;
219220 }
220221
221- path = EnsureAbsolutePath ( path ) ;
222-
223222 if ( ! path . EndsWith ( Path . DirectorySeparatorChar . ToString ( ) ) )
224223 {
225224 path += Path . DirectorySeparatorChar ;
You can’t perform that action at this time.
0 commit comments