@@ -149,6 +149,45 @@ public void Exist_ForFileInfo_WithSameDirectory_ShouldThrow(
149149 . Be ( $ "Expected file \" { fileName } \" to exist { because } , but it did not.") ;
150150 }
151151
152+ #if NET
153+ [ SkippableTheory ]
154+ [ AutoData ]
155+ public void Exist_ForFileSystemInfo_WithExistingFile_ShouldNotThrow (
156+ string path , string pathToTarget , string because )
157+ {
158+ MockFileSystem fileSystem = new ( ) ;
159+ string targetFullPath = fileSystem . Path . GetFullPath ( pathToTarget ) ;
160+ fileSystem . Directory . CreateDirectory ( pathToTarget ) ;
161+ fileSystem . Directory . CreateSymbolicLink ( path , targetFullPath ) ;
162+ IFileSystemInfo ? sut =
163+ fileSystem . Directory . ResolveLinkTarget ( path , false ) ;
164+
165+ sut . Should ( ) . Exist ( because ) ;
166+ }
167+
168+ [ SkippableTheory ]
169+ [ AutoData ]
170+ public void Exist_ForFileSystemInfo_WithoutExistingFile_ShouldThrow (
171+ string path , string pathToTarget , string because )
172+ {
173+ MockFileSystem fileSystem = new ( ) ;
174+ string targetFullPath = fileSystem . Path . GetFullPath ( pathToTarget ) ;
175+ fileSystem . Directory . CreateSymbolicLink ( path , targetFullPath ) ;
176+ IFileSystemInfo ? sut =
177+ fileSystem . Directory . ResolveLinkTarget ( path , false ) ;
178+
179+ Exception ? exception = Record . Exception ( ( ) =>
180+ {
181+ sut . Should ( ) . Exist ( because ) ;
182+ } ) ;
183+
184+ exception . Should ( ) . NotBeNull ( ) ;
185+ exception ! . Message . Should ( )
186+ . Be (
187+ $ "Expected file system info \" { pathToTarget } \" to exist { because } , but it did not.") ;
188+ }
189+ #endif
190+
152191 [ Theory ]
153192 [ AutoData ]
154193 public void NotExist_ForDirectoryInfo_Null_ShouldThrow ( string because )
@@ -275,4 +314,43 @@ public void NotExist_ForFileInfo_WithSameDirectory_ShouldNotThrow(
275314
276315 sut . Should ( ) . NotExist ( because ) ;
277316 }
317+
318+ #if NET
319+ [ SkippableTheory ]
320+ [ AutoData ]
321+ public void NotExist_ForFileSystemInfo_WithExistingFile_ShouldThrow (
322+ string path , string pathToTarget , string because )
323+ {
324+ MockFileSystem fileSystem = new ( ) ;
325+ string targetFullPath = fileSystem . Path . GetFullPath ( pathToTarget ) ;
326+ fileSystem . Directory . CreateDirectory ( pathToTarget ) ;
327+ fileSystem . Directory . CreateSymbolicLink ( path , targetFullPath ) ;
328+ IFileSystemInfo ? sut =
329+ fileSystem . Directory . ResolveLinkTarget ( path , false ) ;
330+
331+ Exception ? exception = Record . Exception ( ( ) =>
332+ {
333+ sut . Should ( ) . NotExist ( because ) ;
334+ } ) ;
335+
336+ exception . Should ( ) . NotBeNull ( ) ;
337+ exception ! . Message . Should ( )
338+ . Be (
339+ $ "Expected file system info \" { pathToTarget } \" not to exist { because } , but it did.") ;
340+ }
341+
342+ [ SkippableTheory ]
343+ [ AutoData ]
344+ public void NotExist_ForFileSystemInfo_WithoutExistingFile_ShouldNotThrow (
345+ string path , string pathToTarget , string because )
346+ {
347+ MockFileSystem fileSystem = new ( ) ;
348+ string targetFullPath = fileSystem . Path . GetFullPath ( pathToTarget ) ;
349+ fileSystem . Directory . CreateSymbolicLink ( path , targetFullPath ) ;
350+ IFileSystemInfo ? sut =
351+ fileSystem . Directory . ResolveLinkTarget ( path , false ) ;
352+
353+ sut . Should ( ) . NotExist ( because ) ;
354+ }
355+ #endif
278356}
0 commit comments