Files
poli0981andClaude Opus 4.8 9332722997 feat(recipes): command chains / macros with stop-on-error (v-next Đợt 4)
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>
2026-06-19 14:51:39 +07:00

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
}