@@ -50,6 +50,20 @@ public void MockFileInfo_Exists_ShouldReturnFalseIfFileDoesNotExistInMemoryFileS
5050 Assert . IsFalse ( result ) ;
5151 }
5252
53+ [ Test ]
54+ public void MockFileInfo_Exists_ShouldRetunFalseIfPathLeadsToDirectory ( )
55+ {
56+ var fileSystem = new MockFileSystem ( new Dictionary < string , MockFileData >
57+ {
58+ { XFS . Path ( @"c:\a\b\c.txt" ) , new MockFileData ( "Demo text content" ) } ,
59+ } ) ;
60+ var fileInfo = new MockFileInfo ( fileSystem , XFS . Path ( @"c:\a\b" ) ) ;
61+
62+ var result = fileInfo . Exists ;
63+
64+ Assert . IsFalse ( result ) ;
65+ }
66+
5367 [ Test ]
5468 public void MockFileInfo_Length_ShouldReturnLengthOfFileInMemoryFileSystem ( )
5569 {
@@ -82,6 +96,21 @@ public void MockFileInfo_Length_ShouldThrowFileNotFoundExceptionIfFileDoesNotExi
8296 Assert . AreEqual ( XFS . Path ( @"c:\foo.txt" ) , ex . FileName ) ;
8397 }
8498
99+ [ Test ]
100+ public void MockFileInfo_Length_ShouldThrowFileNotFoundExceptionIfPathLeadsToDirectory ( )
101+ {
102+ const string fileContent = "Demo text content" ;
103+ var fileSystem = new MockFileSystem ( new Dictionary < string , MockFileData >
104+ {
105+ { XFS . Path ( @"c:\a\b\c.txt" ) , new MockFileData ( fileContent ) } ,
106+ } ) ;
107+ var fileInfo = new MockFileInfo ( fileSystem , XFS . Path ( @"c:\a\b" ) ) ;
108+
109+ var ex = Assert . Throws < FileNotFoundException > ( ( ) => fileInfo . Length . ToString ( CultureInfo . InvariantCulture ) ) ;
110+
111+ Assert . AreEqual ( XFS . Path ( @"c:\a\b" ) , ex . FileName ) ;
112+ }
113+
85114 [ Test ]
86115 public void MockFileInfo_CreationTimeUtc_ShouldReturnCreationTimeUtcOfFileInMemoryFileSystem ( )
87116 {
0 commit comments