Resolve Worker.Tests-008..015 code-review findings

Worker.Tests-008: moved the misplaced WorkerLogRedactor test out of
VariantConverterTests into Bootstrap/WorkerLogRedactorTests.

Worker.Tests-009: renamed 46 snake_case alarm-test methods to PascalCase
Method_Scenario_Expectation.

Worker.Tests-010: replaced a weak Assert.Contains with an exact assertion
against the real diagnostic message and corrected the XML doc.

Worker.Tests-011: renamed and re-documented a cancellation test that
overstated what it proved.

Worker.Tests-012: added an oversized-frame (MessageTooLarge) test; renamed
the mislabeled zero-length-payload test.

Worker.Tests-013: removed the fixed-100ms ThrowIfCompletedAsync helper; the
caller now races runTask deterministically.

Worker.Tests-014: consolidated duplicated test fakes/helpers
(FakeRuntimeSession, NoopComApartmentInitializer, NoopEventSink, frame
helpers) into a shared TestSupport namespace.

Worker.Tests-015: added MxAccessEventQueue coverage for drain-all (maxEvents
0), empty-queue drain, and enqueue-after-fault.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-05-18 22:59:07 -04:00
parent 9582de077b
commit 371bcb3f91
19 changed files with 507 additions and 512 deletions
@@ -18,7 +18,7 @@ public sealed class AlarmDispatcherTests
private const string SessionId = "session-001";
[Fact]
public void TransitionEvent_lands_in_queue_with_mapped_fields()
public void OnTransition_WhenAlarmTransitionRaised_LandsInQueueWithMappedFields()
{
FakeAlarmConsumer consumer = new FakeAlarmConsumer();
MxAccessEventQueue queue = new MxAccessEventQueue();
@@ -64,7 +64,7 @@ public sealed class AlarmDispatcherTests
}
[Fact]
public void Consecutive_unchanged_state_does_not_emit_a_transition()
public void OnTransition_WithConsecutiveUnchangedState_DoesNotEmitTransition()
{
// Mapper.MapTransition returns Unspecified when the state didn't
// change; the dispatcher should drop the event before queueing.
@@ -94,7 +94,7 @@ public sealed class AlarmDispatcherTests
[InlineData(MxAlarmStateKind.UnackAlm, MxAlarmStateKind.AckAlm, AlarmTransitionKind.Acknowledge)]
[InlineData(MxAlarmStateKind.UnackAlm, MxAlarmStateKind.UnackRtn, AlarmTransitionKind.Clear)]
[InlineData(MxAlarmStateKind.UnackRtn, MxAlarmStateKind.UnackAlm, AlarmTransitionKind.Raise)]
public void Transition_kind_follows_state_table(
public void MapTransition_ForEachStatePair_FollowsStateTable(
MxAlarmStateKind previous,
MxAlarmStateKind current,
AlarmTransitionKind expected)
@@ -123,7 +123,7 @@ public sealed class AlarmDispatcherTests
}
[Fact]
public void Subscribe_forwards_to_consumer()
public void Subscribe_WhenInvoked_ForwardsToConsumer()
{
FakeAlarmConsumer consumer = new FakeAlarmConsumer();
using AlarmDispatcher dispatcher = new AlarmDispatcher(
@@ -136,7 +136,7 @@ public sealed class AlarmDispatcherTests
}
[Fact]
public void Acknowledge_forwards_to_consumer_with_full_operator_identity()
public void Acknowledge_WhenInvoked_ForwardsToConsumerWithFullOperatorIdentity()
{
FakeAlarmConsumer consumer = new FakeAlarmConsumer();
consumer.AcknowledgeReturn = 0;
@@ -159,7 +159,7 @@ public sealed class AlarmDispatcherTests
}
[Fact]
public void AcknowledgeByName_forwards_to_consumer_with_full_tuple()
public void AcknowledgeByName_WhenInvoked_ForwardsToConsumerWithFullTuple()
{
FakeAlarmConsumer consumer = new FakeAlarmConsumer { AcknowledgeReturn = 0 };
using AlarmDispatcher dispatcher = new AlarmDispatcher(
@@ -185,7 +185,7 @@ public sealed class AlarmDispatcherTests
}
[Fact]
public void SnapshotActiveAlarms_maps_records_to_protos()
public void SnapshotActiveAlarms_WhenConsumerHasRecords_MapsRecordsToProtos()
{
FakeAlarmConsumer consumer = new FakeAlarmConsumer();
DateTime ts = new DateTime(2026, 5, 1, 17, 26, 14, 709, DateTimeKind.Utc);
@@ -233,7 +233,7 @@ public sealed class AlarmDispatcherTests
}
[Fact]
public void Dispose_unsubscribes_handler_and_disposes_consumer()
public void Dispose_WhenSubscribed_UnsubscribesHandlerAndDisposesConsumer()
{
FakeAlarmConsumer consumer = new FakeAlarmConsumer();
MxAccessEventQueue queue = new MxAccessEventQueue();