refactor(commons): FlowTraceCollector.Add(lowPriority:) instead of a fourth public method (Commons method-count constraint)

This commit is contained in:
Joseph Doherty
2026-09-09 11:28:01 -04:00
parent befb0e3805
commit b73962831c
2 changed files with 29 additions and 35 deletions
@@ -139,10 +139,10 @@ public class FlowTraceCollectorTests
/// <summary>D7 (2026-09-09): the low-priority lane stops short of the event cap so the
/// step rows a run emits at the end always have room.</summary>
[Fact]
public void AddLowPriority_StopsBeforeTheReserve_AndSetsLogsTruncated()
public void Add_LowPriority_StopsBeforeTheReserve_AndSetsLogsTruncated()
{
var c = new FlowTraceCollector(maxEvents: 60, maxBytes: 1_000_000); // reserve = 50 → low-priority stops at 10
for (var i = 0; i < 12; i++) c.AddLowPriority(Evt());
for (var i = 0; i < 12; i++) c.Add(Evt(), lowPriority: true);
Assert.Equal(10, c.Count);
Assert.True(c.LogsTruncated);
@@ -155,11 +155,11 @@ public class FlowTraceCollectorTests
/// <summary>D7 (2026-09-09): the low-priority lane also stops short of the byte budget.</summary>
[Fact]
public void AddLowPriority_RespectsByteShare()
public void Add_LowPriority_RespectsByteShare()
{
var c = new FlowTraceCollector(maxEvents: 500, maxBytes: 1_000); // 75% = 750 chars
c.AddLowPriority(Evt(details: new string('x', 600)));
c.AddLowPriority(Evt(details: new string('x', 200)));
c.Add(Evt(details: new string('x', 600)), lowPriority: true);
c.Add(Evt(details: new string('x', 200)), lowPriority: true);
Assert.Equal(1, c.Count);
Assert.True(c.LogsTruncated);
@@ -167,15 +167,15 @@ public class FlowTraceCollectorTests
/// <summary>D7 (2026-09-09): the reserve floors at 1, so a tiny cap still admits one log line.</summary>
[Fact]
public void AddLowPriority_WithTinyCap_StillAllowsOne()
public void Add_LowPriority_WithTinyCap_StillAllowsOne()
{
var c = new FlowTraceCollector(maxEvents: 20, maxBytes: 1_000_000); // max(1, 20-50) = 1
c.AddLowPriority(Evt());
c.Add(Evt(), lowPriority: true);
Assert.Equal(1, c.Count);
Assert.False(c.LogsTruncated);
c.AddLowPriority(Evt());
c.Add(Evt(), lowPriority: true);
Assert.Equal(1, c.Count);
Assert.True(c.LogsTruncated);
}
@@ -183,13 +183,13 @@ public class FlowTraceCollectorTests
/// <summary>D7 (2026-09-09): <see cref="FlowTraceCollector.Complete"/> closes the low-priority
/// lane too — a late log line is dropped silently, not counted as truncated.</summary>
[Fact]
public void AddLowPriority_IsNoOpAfterComplete()
public void Add_LowPriority_IsNoOpAfterComplete()
{
var c = new FlowTraceCollector();
c.AddLowPriority(Evt());
c.Add(Evt(), lowPriority: true);
c.Complete();
c.AddLowPriority(Evt());
c.Add(Evt(), lowPriority: true);
Assert.Equal(1, c.Count);
Assert.False(c.LogsTruncated);