using PlotLine.Data; using PlotLine.Models; using PlotLine.Services; internal static class ContextMetricsTests { public static void Run() { var windowData = new TimelineData { Project = new(){ProjectID=1}, Books=[new(){BookID=12}], Chapters=[new(){ChapterID=10,BookID=12,ChapterNumber=1},new(){ChapterID=11,BookID=12,ChapterNumber=2}], Scenes=Enumerable.Range(1,16).Reverse().Select(i=>new Scene{SceneID=i,ChapterID=i<=8?10:11,SceneNumber=i<=8?i:i-8}).ToArray() }; var window = WritingContextMetrics.BuildWindow(windowData, [new(){SceneID=9,MetricTypeID=1,Value=0}], [new(){MetricTypeID=1,MetricName="Recorded",IsActive=true,IsEnabledForProject=true,MinValue=0,MaxValue=10}, new(){MetricTypeID=2,MetricName="Empty",IsActive=true,IsEnabledForProject=true,MinValue=-5,MaxValue=5}],9); Check(window.OrderedScenes.Select(s=>s.SceneID).SequenceEqual(Enumerable.Range(4,11)),"Metric window crosses chapters in manuscript order with five neighbours on each side"); Check(window.MetricGraphs.Count==2&&window.MetricGraphs.Single(m=>m.MetricTypeID==2).Points.Count==0,"Enabled metrics without any recorded values still have controls"); Check(window.MetricGraphs.Single(m=>m.MetricTypeID==1).Points.Single().Value==0,"Window retains recorded zero"); var start = WritingContextMetrics.BuildWindow(windowData, [], [], 1); Check(start.OrderedScenes.Select(s=>s.SceneID).SequenceEqual(Enumerable.Range(1,6)),"First scene window does not invent predecessors"); Check(WritingContextMetrics.BuildWindow(windowData, [], [], 999).OrderedScenes.Count==0,"Missing current scene has no fabricated window"); } private static void Check(bool ok,string message){if(!ok)throw new Exception(message);Console.WriteLine("PASS "+message);} }