using PlotLine.Services; internal static class SharedFocusDiagnosticsTests { private sealed class Clock:TimeProvider{public DateTimeOffset Now=DateTimeOffset.UtcNow;public override DateTimeOffset GetUtcNow()=>Now;} public static void Run() { void Check(bool ok,string label){if(!ok)throw new Exception(label);Console.WriteLine("PASS focus diagnostics: "+label);} var clock=new Clock();var trace=new SharedFocusDiagnostics(clock); trace.Write(7,12,"ignored");Check(!trace.Enabled(7,12)&&trace.Read(7,12).Length==0,"disabled by default and retains nothing"); trace.Enable(7,12,true);for(var i=0;i<140;i++)trace.Write(7,12,"observe",sequence:i); var rows=trace.Read(7,12);Check(rows.Length==128&&rows[0].Sequence==12&&rows[^1].Sequence==139,"bounded ordered metadata replaces oldest entries"); Check(trace.Read(8,12).Length==0&&trace.Read(7,13).Length==0,"account and book scopes are isolated"); clock.Now=clock.Now.AddMinutes(11);Check(!trace.Enabled(7,12)&&trace.Read(7,12).Length==0,"opt-in expires without a cleanup timer"); trace.Enable(7,12,true);trace.Write(7,12,"observe");trace.Enable(7,12,false);Check(trace.Read(7,12).Length==0,"explicit disable removes retained metadata"); } }