File tree Expand file tree Collapse file tree
System.IO.Abstractions.TestingHelpers.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using NUnit . Framework ;
2+ using System ;
3+ using System . Collections . Generic ;
4+ using System . Text ;
5+
6+ namespace System . IO . Abstractions . TestingHelpers . Tests
7+ {
8+ [ TestFixture ]
9+ public class DirectoryInfoTests
10+ {
11+ [ Test ]
12+ public void Parent_ForRootDirectory_ShouldReturnNull ( )
13+ {
14+ var wrapperFilesystem = new FileSystem ( ) ;
15+
16+ var directoryInfo = wrapperFilesystem . DirectoryInfo . FromDirectoryName ( "C:\\ " ) ;
17+ var rootsParent = directoryInfo . Parent ;
18+ Assert . IsNull ( rootsParent ) ;
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -227,7 +227,13 @@ public override void SetAccessControl(DirectorySecurity directorySecurity)
227227
228228 public override DirectoryInfoBase Parent
229229 {
230- get { return new DirectoryInfoWrapper ( FileSystem , instance . Parent ) ; }
230+ get
231+ {
232+ if ( instance . Parent == null )
233+ return null ;
234+ else
235+ return new DirectoryInfoWrapper ( FileSystem , instance . Parent ) ;
236+ }
231237 }
232238
233239 public override DirectoryInfoBase Root
You can’t perform that action at this time.
0 commit comments