-
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.
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
| ||
using System.IO; | ||
|
||
namespace Amusoft.DotnetNew.Tests.Internals; | ||
|
||
internal static class PathHelper | ||
{ | ||
public static string AbsoluteTrimPathEnd(string input, int count) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
{ | ||
input = Path.GetDirectoryName(input); | ||
Check warning on line 12 in src/Amusoft.DotnetNew.Tests/Internals/PathHelper.cs
|
||
} | ||
|
||
return input; | ||
Check warning on line 15 in src/Amusoft.DotnetNew.Tests/Internals/PathHelper.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
24 changes: 24 additions & 0 deletions
24
tests/Amusoft.DotnetNew.Tests.UnitTests/Tests/PathHelperTests.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,24 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.CompilerServices; | ||
using Amusoft.DotnetNew.Tests.Internals; | ||
using Amusoft.DotnetNew.Tests.Utility; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Amusoft.DotnetNew.Tests.UnitTests.Tests; | ||
|
||
public class PathHelperTests | ||
{ | ||
[Theory] | ||
[InlineData("/home/runner/work/Amusoft.DotnetNew.Tests/Amusoft.DotnetNew.Tests/tests/Resources/dotnet-library-repo/.template.config/template.json" | ||
, 2, "/home/runner/work/Amusoft.DotnetNew.Tests/Amusoft.DotnetNew.Tests/tests/Resources/dotnet-library-repo")] | ||
[InlineData("/home/runner/work/Amusoft.DotnetNew.Tests/Amusoft.DotnetNew.Tests/tests/Resources/dotnet-library-repo/.template.config/template.json" | ||
, 3, "/home/runner/work/Amusoft.DotnetNew.Tests/Amusoft.DotnetNew.Tests/tests/Resources")] | ||
public void PathTrimming(string input, int trim, string expected) | ||
{ | ||
var o = PathHelper.AbsoluteTrimPathEnd(input, trim); | ||
var r = new CrossPlatformPath(o); | ||
r.ShouldBe(new CrossPlatformPath(expected)); | ||
} | ||
} |