#nullable enable using NUnit.Framework; using ShrinkContext.AppAdapter.Editor; namespace ShrinkContext.AppAdapter.Tests { public class ContextBenchmarkTests { [Test] public void Benchmark_UsesIndexedCandidatesAndRestoresEveryFailedReplacement() { var report = TestAwait.Run(ShrinkContextBenchmarkRunner.RunAsync( unrelatedFiberCount: 10, reloadIterations: 3, failureIterations: 2)); Assert.AreEqual(3, report.ConsumerApplyCount); Assert.AreEqual(12L, report.NotificationDispatchCount); Assert.AreEqual(12L, report.NotificationCandidateVisits, "每次 provider 生命周期有四次键通知,每次只访问目标 consumer"); Assert.Less(report.NotificationCandidateVisits, report.NaiveFiberVisits); Assert.AreEqual(2, report.RestoredFailureCount); Assert.GreaterOrEqual(report.NotifyMilliseconds, 0d); Assert.GreaterOrEqual(report.RestoreMilliseconds, 0d); } } }