Implements B2 from docs/Extra.md Part 1 (Macro / recipe). - Domain: Recipe (named, ordered list of catalog command ids). - Application: IRecipeStore port + pure RecipeFlow.ShouldStop (stop on failure / cancel / reboot-required). - Infrastructure: JsonRecipeStore -> %AppData%\CommandForge\recipes.json (source-gen, schema version, corrupt-file fallback). No telemetry; recipes reference only vetted catalog ids. - WPF: ExecutionViewModel.RunRecipeAsync runs steps sequentially through the same broker session (one UAC for an all-admin chain), streaming a per-step header and stopping per RecipeFlow. New Recipes shell section (sidebar + View menu) with RecipesViewModel/RecipesView: build/reorder/remove steps from the catalog, save/delete recipes, and Run with a single aggregated confirmation (warns on dangerous steps). Each finished step is recorded in the execution history. - EN/VI .resx keys; tests for RecipeFlow and the recipe store. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using CommandForge.Application.Recipes;
|
|
using CommandForge.Domain;
|
|
|
|
namespace CommandForge.Tests;
|
|
|
|
/// <summary>Tests the pure recipe stop-on-error/restart/cancel decision.</summary>
|
|
public sealed class RecipeFlowTests
|
|
{
|
|
private static ExecutionResult Result(bool success = true, bool cancelled = false, bool restart = false)
|
|
=> new()
|
|
{
|
|
ExitCode = success ? 0 : 1,
|
|
Success = success,
|
|
Duration = TimeSpan.Zero,
|
|
Cancelled = cancelled,
|
|
RequiresRestart = restart,
|
|
};
|
|
|
|
[Fact]
|
|
public void ShouldStop_False_OnPlainSuccess()
|
|
=> Assert.False(RecipeFlow.ShouldStop(Result()));
|
|
|
|
[Fact]
|
|
public void ShouldStop_True_OnFailure()
|
|
=> Assert.True(RecipeFlow.ShouldStop(Result(success: false)));
|
|
|
|
[Fact]
|
|
public void ShouldStop_True_OnCancelled()
|
|
=> Assert.True(RecipeFlow.ShouldStop(Result(cancelled: true)));
|
|
|
|
[Fact]
|
|
public void ShouldStop_True_OnRestartRequired()
|
|
=> Assert.True(RecipeFlow.ShouldStop(Result(restart: true))); // 3010: success-with-reboot, still stop
|
|
}
|