-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update deps and add Path.HasTrailingDirectorySeparator
- Loading branch information
Showing
10 changed files
with
165 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/CommonUtilities.FileSystem/test/PathExtensionsTest.HasLeadingPathSeparator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.IO.Abstractions; | ||
using AnakinRaW.CommonUtilities.Testing; | ||
using Xunit; | ||
|
||
namespace AnakinRaW.CommonUtilities.FileSystem.Test; | ||
|
||
public class HasLeadingPathSeparatorTest | ||
{ | ||
// Using the actual file system here since we are not modifying it. | ||
// Also, we want to assure that everything works on the real system, | ||
// not that an arbitrary test implementation works. | ||
private readonly IFileSystem _fileSystem = new System.IO.Abstractions.FileSystem(); | ||
|
||
[Theory] | ||
[InlineData("")] | ||
[InlineData(null)] | ||
public void Test_HasLeadingPathSeparator(string? input) | ||
{ | ||
Assert.False(_fileSystem.Path.HasLeadingDirectorySeparator(input)); | ||
Assert.False(_fileSystem.Path.HasLeadingDirectorySeparator(input.AsSpan())); | ||
} | ||
|
||
public static TheoryData<string, bool> TestData_StartsWithDirectorySeparator_Windows => new() | ||
{ | ||
{ @"\", true }, | ||
{ @"/", true }, | ||
{ @"C:\folder\", false }, | ||
{ @"C:/folder/", false }, | ||
{ @"C:\", false }, | ||
{ @"C:/", false }, | ||
{ @"\\", true }, | ||
{ @"//", true }, | ||
{ @"\\server\share\", true }, | ||
{ @"\\?\UNC\a\", true }, | ||
{ @"\\?\C:\", true }, | ||
{ @"\\?\UNC\", true }, | ||
{ @"\folder", true }, | ||
{ @"folder", false }, | ||
}; | ||
|
||
[PlatformSpecificTheory(TestPlatformIdentifier.Windows)] | ||
[MemberData(nameof(TestData_StartsWithDirectorySeparator_Windows))] | ||
public void Test_HasLeadingPathSeparator_Windows(string input, bool expected) | ||
{ | ||
Assert.Equal(expected, _fileSystem.Path.HasLeadingDirectorySeparator(input)); | ||
Assert.Equal(expected, _fileSystem.Path.HasLeadingDirectorySeparator(input.AsSpan())); | ||
} | ||
|
||
|
||
public static TheoryData<string, bool> TestData_StartsWithDirectorySeparator_Linux => new() | ||
{ | ||
{ @"/", true }, | ||
{ @"/folder/", true }, | ||
{ @"//", true }, | ||
{ @"folder", false }, | ||
{ @"/folder", true } | ||
}; | ||
|
||
[PlatformSpecificTheory(TestPlatformIdentifier.Linux)] | ||
[MemberData(nameof(TestData_StartsWithDirectorySeparator_Linux))] | ||
public void Test_HasLeadingPathSeparator_Linux(string input, bool expected) | ||
{ | ||
Assert.Equal(expected, _fileSystem.Path.HasLeadingDirectorySeparator(input)); | ||
Assert.Equal(expected, _fileSystem.Path.HasLeadingDirectorySeparator(input.AsSpan())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters