using StellaOps.Bench.ScannerAnalyzers; using StellaOps.Bench.ScannerAnalyzers.Baseline; using StellaOps.Bench.ScannerAnalyzers.Reporting; using Xunit; namespace StellaOps.Bench.ScannerAnalyzers.Tests; public sealed class BenchmarkScenarioReportTests { [Fact] public void RegressionRatio_ComputedWhenBaselinePresent() { var result = new ScenarioResult( "scenario", "Scenario", SampleCount: 5, MeanMs: 10, P95Ms: 12, MaxMs: 20, Iterations: 5, ThresholdMs: 5000); var baseline = new BaselineEntry( "scenario", Iterations: 5, SampleCount: 5, MeanMs: 8, P95Ms: 11, MaxMs: 15); var report = new BenchmarkScenarioReport(result, baseline, regressionLimit: 1.2); Assert.True(report.MaxRegressionRatio.HasValue); Assert.Equal(20d / 15d, report.MaxRegressionRatio.Value, 6); Assert.True(report.RegressionBreached); Assert.Contains("+33.3%", report.BuildRegressionFailureMessage()); } [Fact] public void RegressionRatio_NullWhenBaselineMissing() { var result = new ScenarioResult( "scenario", "Scenario", SampleCount: 5, MeanMs: 10, P95Ms: 12, MaxMs: 20, Iterations: 5, ThresholdMs: 5000); var report = new BenchmarkScenarioReport(result, baseline: null, regressionLimit: 1.2); Assert.Null(report.MaxRegressionRatio); Assert.False(report.RegressionBreached); Assert.Null(report.BuildRegressionFailureMessage()); } }