Skip to content

Commit 2795969

Browse files
authored
test: Extended Command Help and Command Build tests (#31)
1 parent 3bf4cd2 commit 2795969

17 files changed

+41
-6
lines changed

src/NetEvolve.ForgingBlazor/Commands/CommandBuild.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public CommandBuild(IServiceProvider serviceProvider)
3434
{
3535
_serviceProvider = serviceProvider;
3636

37+
Add(CommandOptions.ContentPath);
3738
Add(CommandOptions.Environment);
3839
Add(CommandOptions.IncludeDrafts);
3940
Add(CommandOptions.IncludeFuture);

tests/NetEvolve.ForgingBlazor.Tests.Integration/Commands/CommandBuildTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ public async ValueTask Build_DefaultArguments_GeneratesStaticContent(string[] ar
1010

1111
if (args is not null && args.Length != 0)
1212
{
13-
args = [.. args, directory.Path];
13+
args = [.. args, directory.Path, "--content-path", "_setup/content"];
1414
}
1515
else
1616
{
17-
args = ["build"];
17+
args = ["build", "--content-path", "_setup/Content"];
1818
}
19+
1920
await Helper.VerifyStaticContent(directory.Path, args).ConfigureAwait(false);
2021
}
2122

tests/NetEvolve.ForgingBlazor.Tests.Integration/Commands/CommandHelpTests.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@ public async ValueTask Help_Theory_Expected(string[] args)
1313

1414
var app = builder.Build();
1515
await using var output = new StringWriter();
16+
await using var error = new StringWriter();
1617

17-
if (app is Application Application)
18+
if (app is Application application)
1819
{
19-
Application.InvocationConfiguration = new() { Output = output };
20+
application.InvocationConfiguration = new() { Error = error, Output = output };
2021
}
2122

2223
_ = await app.RunAsync().ConfigureAwait(false);
2324

24-
_ = await Verify(new { args, output }).DontIgnoreEmptyCollections().HashParameters();
25+
_ = await Verify(
26+
new
27+
{
28+
args,
29+
error,
30+
output,
31+
}
32+
)
33+
.DontIgnoreEmptyCollections()
34+
.HashParameters();
2535
}
2636

2737
public static IEnumerable<Func<string[]>> GetHelpArguments =>

tests/NetEvolve.ForgingBlazor.Tests.Integration/Predefined.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal static class Predefined
99
[ModuleInitializer]
1010
public static void Init()
1111
{
12-
Verifier.DerivePathInfo(
12+
DerivePathInfo(
1313
(sourceFile, projectDirectory, method, type) =>
1414
{
1515
var snapshots = Path.Combine(projectDirectory, "_snapshots", Namer.TargetFrameworkNameAndVersion);
@@ -18,6 +18,9 @@ public static void Init()
1818
}
1919
);
2020

21+
VerifierSettings.SortJsonObjects();
22+
VerifierSettings.SortPropertiesAlphabetically();
23+
2124
VerifierSettings.AutoVerify(includeBuildServer: false, throwException: true);
2225
}
2326
}

tests/NetEvolve.ForgingBlazor.Tests.Integration/_setup/content/.gitstay

Whitespace-only changes.

tests/NetEvolve.ForgingBlazor.Tests.Integration/_snapshots/DotNet10_0/Help_Theory_Expected.CommandHelpTests_25a03f3b48369ce7.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
create,
44
--help
55
],
6+
error: ,
67
output:
78
Description:
89
Creates a new page for a Forging Blazor application.

tests/NetEvolve.ForgingBlazor.Tests.Integration/_snapshots/DotNet10_0/Help_Theory_Expected.CommandHelpTests_3cb5690aa64d0539.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
build,
44
--help
55
],
6+
error: ,
67
output:
78
Description:
89
Builds and generates static content for a Forging Blazor application.
@@ -11,6 +12,7 @@ Usage:
1112
NetEvolve.ForgingBlazor.Tests.Integration build [options]
1213

1314
Options:
15+
--content-path <content-path> Specifies the absolute or relative path to the content directory [default: content]
1416
-e, --environment <environment> Specifies the execution environment (e.g., Development, Staging, Production) [default: Production]
1517
--include-drafts Includes draft pages in the build output
1618
--include-future Includes pages with future publication dates in the build output

tests/NetEvolve.ForgingBlazor.Tests.Integration/_snapshots/DotNet10_0/Help_Theory_Expected.CommandHelpTests_7482efceccfc847a.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
serve,
44
--help
55
],
6+
error: ,
67
output:
78
Description:
89
Starts a development server for a Forging Blazor application.

tests/NetEvolve.ForgingBlazor.Tests.Integration/_snapshots/DotNet10_0/Help_Theory_Expected.CommandHelpTests_a46afb280312df84.verified.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
args: [],
3+
error:
4+
Required command was not provided.
5+
6+
,
37
output:
48
Description:
59
Command-line interface for managing Forging Blazor applications.

tests/NetEvolve.ForgingBlazor.Tests.Integration/_snapshots/DotNet10_0/Help_Theory_Expected.CommandHelpTests_cf823c7fea89c954.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
args: [
33
-h
44
],
5+
error: ,
56
output:
67
Description:
78
Command-line interface for managing Forging Blazor applications.

0 commit comments

Comments
 (0)