32 lines
2.4 KiB
C#
32 lines
2.4 KiB
C#
using System.Text.Json;
|
|
using PlotLine.Data;
|
|
using PlotLine.Services;
|
|
internal static class WritingSolverPayoffTests
|
|
{
|
|
public static void Audit()
|
|
{
|
|
void Check(bool ok,string reason){if(!ok)throw new Exception(reason);}
|
|
var root=WritingSolverCuratedV2Tests.Root();
|
|
var payoff=new WritingSolverPayoff(Path.Combine(root,"PlotLine/Content/WritingSolver/Presentation/payoff-v1.json"));
|
|
var graph=WritingSolverRepository.Parse(File.ReadAllText(Path.Combine(root,"PlotLine/Content/WritingSolver/Candidates/curated-v2-stage1-repair/writing-solver-curated-v2-stage1-repair.json")));
|
|
var before=JsonSerializer.Serialize(graph,WritingSolverRepository.JsonOptions);var results=WritingSolverResultTests.Content();
|
|
Check(payoff.Content.Results.Select(r=>r.Family).Distinct().Count()==7,"Expected seven diagnostic archetypes.");
|
|
foreach(var solution in graph.Solutions)
|
|
{
|
|
var p=payoff.For(solution.Id);Check(p.Action.Length>50,"Missing practical action.");
|
|
var approved=results.Catalog.Results.Single(r=>r.Solution==solution.Id);
|
|
Check((p.Family=="workflow")== (approved.Secondary is not null),"Workflow must use an approved secondary, without padding single-feature results.");
|
|
}
|
|
foreach(var entry in payoff.Content.Uncertainty)Check(graph.Nodes.Any(n=>n.Id==entry.Node&&n.Choices.Any(c=>c.Id==entry.Choice)),"Invalid uncertainty classification.");
|
|
foreach(var node in graph.Nodes)
|
|
{
|
|
var choices=payoff.OrderedChoices(node).ToArray();var seen=false;
|
|
foreach(var choice in choices){if(payoff.IsUncertain(node,choice))seen=true;else Check(!seen,"Uncertainty was not last.");}
|
|
Check(choices.Select(c=>c.Id).Order().SequenceEqual(node.Choices.Where(c=>c.Active).Select(c=>c.Id).Order()),"Choices were added or removed.");
|
|
}
|
|
foreach(var id in new[]{"final-cast","final-progression"}){var node=graph.Nodes.Single(n=>n.Id==id);Check(payoff.OrderedChoices(node).Last().Id=="unsure","Known mixed-order uncertainty was not corrected.");}
|
|
Check(!payoff.IsUncertain(graph.Nodes.Single(n=>n.Id=="story-problem"),graph.Nodes.Single(n=>n.Id=="story-problem").Choices.Single(c=>c.Id=="scene-contribution")),"A substantive symptom was mistaken for an unknown answer.");
|
|
Check(before==JsonSerializer.Serialize(graph,WritingSolverRepository.JsonOptions),"Presentation changed graph/scoring/routing/order fields.");
|
|
}
|
|
}
|