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 current = wrapperFilesystem . Directory . GetCurrentDirectory ( ) ;
17+ var root = wrapperFilesystem . DirectoryInfo . FromDirectoryName ( current ) . Root ;
18+ var rootsParent = root . Parent ;
19+ Assert . IsNull ( rootsParent ) ;
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -227,7 +227,17 @@ 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+ {
234+ return null ;
235+ }
236+ else
237+ {
238+ return new DirectoryInfoWrapper ( FileSystem , instance . Parent ) ;
239+ }
240+ }
231241 }
232242
233243 public override DirectoryInfoBase Root
You can’t perform that action at this time.
0 commit comments