File tree Expand file tree Collapse file tree 6 files changed +23
-2
lines changed
Pathy.ApiVerificationTests/ApprovedApi Expand file tree Collapse file tree 6 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,15 @@ namespace Pathy
1111 public bool FileExists { get; }
1212 public bool IsDirectory { get; }
1313 public bool IsFile { get; }
14+ public bool IsNull { get; }
1415 public bool IsRooted { get; }
1516 public string Name { get; }
1617 public Pathy.ChainablePath Parent { get; }
1718 public Pathy.ChainablePath Root { get; }
1819 public static Pathy.ChainablePath Current { get; }
1920 public static Pathy.ChainablePath Empty { get; }
2021 public static Pathy.ChainablePath New { get; }
22+ public static Pathy.ChainablePath Null { get; }
2123 public static Pathy.ChainablePath Temp { get; }
2224 public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
2325 public bool HasExtension(string extension) { }
Original file line number Diff line number Diff line change @@ -11,13 +11,15 @@ namespace Pathy
1111 public bool FileExists { get; }
1212 public bool IsDirectory { get; }
1313 public bool IsFile { get; }
14+ public bool IsNull { get; }
1415 public bool IsRooted { get; }
1516 public string Name { get; }
1617 public Pathy.ChainablePath Parent { get; }
1718 public Pathy.ChainablePath Root { get; }
1819 public static Pathy.ChainablePath Current { get; }
1920 public static Pathy.ChainablePath Empty { get; }
2021 public static Pathy.ChainablePath New { get; }
22+ public static Pathy.ChainablePath Null { get; }
2123 public static Pathy.ChainablePath Temp { get; }
2224 public Pathy.ChainablePath AsRelativeTo(Pathy.ChainablePath basePath) { }
2325 public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
Original file line number Diff line number Diff line change @@ -11,13 +11,15 @@ namespace Pathy
1111 public bool FileExists { get; }
1212 public bool IsDirectory { get; }
1313 public bool IsFile { get; }
14+ public bool IsNull { get; }
1415 public bool IsRooted { get; }
1516 public string Name { get; }
1617 public Pathy.ChainablePath Parent { get; }
1718 public Pathy.ChainablePath Root { get; }
1819 public static Pathy.ChainablePath Current { get; }
1920 public static Pathy.ChainablePath Empty { get; }
2021 public static Pathy.ChainablePath New { get; }
22+ public static Pathy.ChainablePath Null { get; }
2123 public static Pathy.ChainablePath Temp { get; }
2224 public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
2325 public bool HasExtension(string extension) { }
Original file line number Diff line number Diff line change @@ -11,13 +11,15 @@ namespace Pathy
1111 public bool FileExists { get; }
1212 public bool IsDirectory { get; }
1313 public bool IsFile { get; }
14+ public bool IsNull { get; }
1415 public bool IsRooted { get; }
1516 public string Name { get; }
1617 public Pathy.ChainablePath Parent { get; }
1718 public Pathy.ChainablePath Root { get; }
1819 public static Pathy.ChainablePath Current { get; }
1920 public static Pathy.ChainablePath Empty { get; }
2021 public static Pathy.ChainablePath New { get; }
22+ public static Pathy.ChainablePath Null { get; }
2123 public static Pathy.ChainablePath Temp { get; }
2224 public Pathy.ChainablePath AsRelativeTo(Pathy.ChainablePath basePath) { }
2325 public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
Original file line number Diff line number Diff line change @@ -568,7 +568,7 @@ public void Empty_path_returned_when_no_match_found()
568568 var result = childDir . FindParentWithFileMatching ( "*.sln" ) ;
569569
570570 // Assert
571- result . Should ( ) . Be ( ChainablePath . Empty ) ;
571+ result . Should ( ) . Be ( ChainablePath . Null ) ;
572572 }
573573
574574 [ Fact ]
@@ -765,7 +765,7 @@ public void Returns_empty_for_non_existing_string_paths()
765765 var result = ChainablePath . FindFirst ( nonExistingFile1 . ToString ( ) , nonExistingFile2 . ToString ( ) ) ;
766766
767767 // Assert
768- result . Should ( ) . Be ( ChainablePath . Empty ) ;
768+ result . IsNull . Should ( ) . BeTrue ( ) ;
769769 }
770770
771771 [ Fact ]
Original file line number Diff line number Diff line change @@ -32,6 +32,14 @@ private ChainablePath(string path)
3232 /// </summary>
3333 public static ChainablePath Empty { get ; } = new ( string . Empty ) ;
3434
35+ /// <summary>
36+ /// Represents a <see cref="ChainablePath"/> not pointing to any file or directory.
37+ /// </summary>
38+ /// <remarks>
39+ /// Implements the Null Pattern and should be used as a replacement of <see cref="Empty"/>
40+ /// </remarks>
41+ public static ChainablePath Null { get ; } = new ( string . Empty ) ;
42+
3543 /// <summary>
3644 /// Gets a default, empty <see cref="ChainablePath"/> instance.
3745 /// </summary>
@@ -221,6 +229,11 @@ private static string NormalizeSlashes(string path)
221229 return From ( leftPath . ToString ( ) + additionalPath ) ;
222230 }
223231
232+ /// <summary>
233+ /// Gets a value indicating whether the current <see cref="ChainablePath"/> instance is equal to <see cref="ChainablePath.Null"/>.
234+ /// </summary>
235+ public bool IsNull => Equals ( Null ) ;
236+
224237 /// <summary>
225238 /// Gets the name of the file or directory represented by the current path, without the parent directory.
226239 /// </summary>
You can’t perform that action at this time.
0 commit comments