test: remaining xUnit1051/1031/1030, CS8602/8604, CS0618, CS0219, CS0649, NU1510 fixes (lmxopcua#725)
v2-ci / unit-tests (push) Has been cancelled
v2-ci / unit-tests (push) Has been cancelled
Awaited deadline oracles get the runner token; sync-over-async tests made async; nullable child models asserted via ShouldNotBeNull() return values; obsolete SDK ctors replaced with the telemetry overloads; dead locals/fixture and the redundant DI PackageReference removed. No suppressions. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -237,7 +237,7 @@ public sealed class DeployWatcherTests
|
||||
|
||||
// StopAsync should complete without throwing and within a reasonable window.
|
||||
var stopTask = watcher.StopAsync();
|
||||
var completed = await Task.WhenAny(stopTask, Task.Delay(TimeSpan.FromSeconds(5)));
|
||||
var completed = await Task.WhenAny(stopTask, Task.Delay(TimeSpan.FromSeconds(5), TestContext.Current.CancellationToken));
|
||||
completed.ShouldBe(stopTask);
|
||||
await stopTask; // observe (no) exception
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public sealed class DeployWatcherTests
|
||||
|
||||
// Should not throw, should not hang.
|
||||
var disposeTask = Task.Run(watcher.Dispose, TestContext.Current.CancellationToken);
|
||||
var completed = await Task.WhenAny(disposeTask, Task.Delay(TimeSpan.FromSeconds(5)));
|
||||
var completed = await Task.WhenAny(disposeTask, Task.Delay(TimeSpan.FromSeconds(5), TestContext.Current.CancellationToken));
|
||||
completed.ShouldBe(disposeTask);
|
||||
await disposeTask;
|
||||
}
|
||||
|
||||
+3
-3
@@ -124,7 +124,7 @@ public sealed class HostStatusAggregatorTests
|
||||
|
||||
/// <summary>Verifies that concurrent updates do not corrupt the internal dictionary.</summary>
|
||||
[Fact]
|
||||
public void ConcurrentUpdates_DoNotCorruptDictionary()
|
||||
public async Task ConcurrentUpdates_DoNotCorruptDictionary()
|
||||
{
|
||||
var agg = new HostStatusAggregator();
|
||||
const int threadCount = 8;
|
||||
@@ -138,9 +138,9 @@ public sealed class HostStatusAggregatorTests
|
||||
var state = i % 2 == 0 ? HostState.Running : HostState.Stopped;
|
||||
agg.Update(Status(hostName, state));
|
||||
}
|
||||
})).ToArray();
|
||||
}, TestContext.Current.CancellationToken)).ToArray();
|
||||
|
||||
Task.WaitAll(tasks, TestContext.Current.CancellationToken);
|
||||
await Task.WhenAll(tasks).WaitAsync(TestContext.Current.CancellationToken);
|
||||
agg.Snapshot().Count.ShouldBeLessThanOrEqualTo(32);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ public sealed class EventPumpDispatchFaultTests
|
||||
|
||||
await subscriber.EmitAsync(7);
|
||||
|
||||
(await Task.WhenAny(fault.Task, Task.Delay(WaitMs))).ShouldBe(fault.Task,
|
||||
(await Task.WhenAny(fault.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(fault.Task,
|
||||
"a dispatch-loop exit must be reported as a stream fault");
|
||||
(await fault.Task).ShouldBeOfType<InvalidDataException>();
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public sealed class EventPumpDispatchFaultTests
|
||||
|
||||
await subscriber.EmitAsync(7);
|
||||
|
||||
(await Task.WhenAny(delivered.Task, Task.Delay(WaitMs))).ShouldBe(delivered.Task);
|
||||
(await Task.WhenAny(delivered.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(delivered.Task);
|
||||
(await delivered.Task).FullReference.ShouldBe("Tank01.Level");
|
||||
faulted.ShouldBeFalse();
|
||||
}
|
||||
|
||||
+7
-7
@@ -57,7 +57,7 @@ public sealed class EventPumpReplayGapTests
|
||||
|
||||
await subscriber.EmitAsync(GapSentinel(requestedAfter: 100, oldestAvailable: 250));
|
||||
|
||||
(await Task.WhenAny(observed.Task, Task.Delay(WaitMs))).ShouldBe(observed.Task,
|
||||
(await Task.WhenAny(observed.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(observed.Task,
|
||||
"a replay-gap sentinel must reach the driver so it can re-snapshot");
|
||||
var gap = await observed.Task;
|
||||
gap.RequestedAfterSequence.ShouldBe(100UL);
|
||||
@@ -93,7 +93,7 @@ public sealed class EventPumpReplayGapTests
|
||||
pump.Start();
|
||||
|
||||
await subscriber.EmitAsync(GapSentinel(requestedAfter: 1, oldestAvailable: 2));
|
||||
(await Task.WhenAny(gapSeen.Task, Task.Delay(WaitMs))).ShouldBe(gapSeen.Task);
|
||||
(await Task.WhenAny(gapSeen.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(gapSeen.Task);
|
||||
|
||||
// A positive control: follow the sentinel with a real event on the same handle. Without
|
||||
// it, "nothing was dispatched" would also pass on a pump that dispatches nothing at all.
|
||||
@@ -106,7 +106,7 @@ public sealed class EventPumpReplayGapTests
|
||||
SourceTimestamp = Timestamp.FromDateTime(DateTime.UtcNow),
|
||||
});
|
||||
|
||||
(await Task.WhenAny(realValue.Task, Task.Delay(WaitMs))).ShouldBe(realValue.Task,
|
||||
(await Task.WhenAny(realValue.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(realValue.Task,
|
||||
"the pump must keep dispatching real events after a sentinel");
|
||||
(await realValue.Task).Snapshot.Value.ShouldBe(12.5);
|
||||
Volatile.Read(ref dispatched).ShouldBe(1, "only the real event may be dispatched, never the sentinel");
|
||||
@@ -149,7 +149,7 @@ public sealed class EventPumpReplayGapTests
|
||||
|
||||
await subscriber.EmitAsync(GapSentinel(requestedAfter: 5, oldestAvailable: 900));
|
||||
|
||||
(await Task.WhenAny(observed.Task, Task.Delay(WaitMs))).ShouldBe(observed.Task,
|
||||
(await Task.WhenAny(observed.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(observed.Task,
|
||||
"the sentinel must not be droppable by channel back-pressure");
|
||||
(await observed.Task).OldestAvailableSequence.ShouldBe(900UL);
|
||||
|
||||
@@ -187,7 +187,7 @@ public sealed class EventPumpReplayGapTests
|
||||
Quality = 192,
|
||||
});
|
||||
|
||||
(await Task.WhenAny(resumed.Task, Task.Delay(WaitMs))).ShouldBe(resumed.Task,
|
||||
(await Task.WhenAny(resumed.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(resumed.Task,
|
||||
"a failed re-snapshot must not stop the stream that is still delivering");
|
||||
faulted.ShouldBeFalse("a throwing gap callback is not a transport fault");
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public sealed class EventPumpReplayGapTests
|
||||
|
||||
subscriber.CompleteStream();
|
||||
|
||||
(await Task.WhenAny(faultObserved.Task, Task.Delay(WaitMs))).ShouldBe(faultObserved.Task,
|
||||
(await Task.WhenAny(faultObserved.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(faultObserved.Task,
|
||||
"a server-completed stream is as fatal as a faulted one and must reach the supervisor");
|
||||
(await faultObserved.Task).Message.ShouldContain("closed or evicted");
|
||||
}
|
||||
@@ -277,7 +277,7 @@ public sealed class EventPumpReplayGapTests
|
||||
SourceTimestamp = Timestamp.FromDateTime(DateTime.UtcNow),
|
||||
});
|
||||
|
||||
(await Task.WhenAny(bothSeen.Task, Task.Delay(WaitMs))).ShouldBe(bothSeen.Task);
|
||||
(await Task.WhenAny(bothSeen.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(bothSeen.Task);
|
||||
|
||||
lock (received)
|
||||
{
|
||||
|
||||
+4
-4
@@ -35,7 +35,7 @@ public sealed class EventPumpStreamFaultTests
|
||||
// Drop the gw stream — RunAsync's await foreach throws.
|
||||
subscriber.FaultStream(new IOException("simulated gateway transport drop"));
|
||||
|
||||
var completed = await Task.WhenAny(faultObserved.Task, Task.Delay(WaitMs));
|
||||
var completed = await Task.WhenAny(faultObserved.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken));
|
||||
completed.ShouldBe(faultObserved.Task,
|
||||
"EventPump must invoke onStreamFault when the gw StreamEvents stream faults");
|
||||
(await faultObserved.Task).ShouldBeOfType<IOException>();
|
||||
@@ -69,9 +69,9 @@ public sealed class EventPumpStreamFaultTests
|
||||
|
||||
subscriber.FaultStream(new IOException("simulated gateway transport drop"));
|
||||
|
||||
(await Task.WhenAny(reopenRan.Task, Task.Delay(WaitMs))).ShouldBe(reopenRan.Task,
|
||||
(await Task.WhenAny(reopenRan.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(reopenRan.Task,
|
||||
"stream fault must trigger the supervisor's reopen path");
|
||||
(await Task.WhenAny(replayRan.Task, Task.Delay(WaitMs))).ShouldBe(replayRan.Task,
|
||||
(await Task.WhenAny(replayRan.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(replayRan.Task,
|
||||
"stream fault must trigger the supervisor's replay path");
|
||||
|
||||
await supervisor.WaitForHealthyAsync(new CancellationTokenSource(WaitMs).Token);
|
||||
@@ -114,7 +114,7 @@ public sealed class EventPumpStreamFaultTests
|
||||
|
||||
await resubscribed.EmitAsync(itemHandle: 7, value: 123.0);
|
||||
|
||||
var completed = await Task.WhenAny(resumed.Task, Task.Delay(WaitMs));
|
||||
var completed = await Task.WhenAny(resumed.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken));
|
||||
completed.ShouldBe(resumed.Task,
|
||||
"a fresh EventPump created after a fault must resume dispatching OnDataChange");
|
||||
(await resumed.Task).FullReference.ShouldBe("Tank.Level");
|
||||
|
||||
+3
-3
@@ -251,7 +251,7 @@ public sealed class GalaxyDriverFixRound1Tests
|
||||
await WaitUntilAsync(() => Volatile.Read(ref deploys.Opened) == 1, "the deploy watch must open");
|
||||
await deploys.PushAsync(1, new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero)); // bootstrap
|
||||
await deploys.PushAsync(2, new DateTimeOffset(2026, 1, 2, 0, 0, 0, TimeSpan.Zero));
|
||||
(await Task.WhenAny(platforms.Entered.Task, Task.Delay(WaitMs))).ShouldBe(platforms.Entered.Task,
|
||||
(await Task.WhenAny(platforms.Entered.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(platforms.Entered.Task,
|
||||
"the first rediscovery pass must be parked mid-fetch");
|
||||
|
||||
await deploys.PushAsync(3, new DateTimeOffset(2026, 1, 3, 0, 0, 0, TimeSpan.Zero));
|
||||
@@ -308,7 +308,7 @@ public sealed class GalaxyDriverFixRound1Tests
|
||||
var subscribeCallsBefore = sub.SubscribeCalls;
|
||||
try
|
||||
{
|
||||
(await Task.WhenAny(sub.UnsubscribeEntered.Task, Task.Delay(WaitMs))).ShouldBe(sub.UnsubscribeEntered.Task,
|
||||
(await Task.WhenAny(sub.UnsubscribeEntered.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(sub.UnsubscribeEntered.Task,
|
||||
"the teardown must be parked inside the probe watcher's unsubscribe");
|
||||
shutdown.IsCompleted.ShouldBeFalse();
|
||||
|
||||
@@ -391,7 +391,7 @@ public sealed class GalaxyDriverFixRound1Tests
|
||||
await driver.SubscribeAsync(["Tank01.Level"], TimeSpan.Zero, CancellationToken.None);
|
||||
|
||||
var replay = driver.InvokeReplayForTestAsync(CancellationToken.None);
|
||||
(await Task.WhenAny(sub.SubscribeEntered.Task, Task.Delay(WaitMs))).ShouldBe(sub.SubscribeEntered.Task,
|
||||
(await Task.WhenAny(sub.SubscribeEntered.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(sub.SubscribeEntered.Task,
|
||||
"the replay must be parked inside its SubscribeBulk");
|
||||
|
||||
await driver.ShutdownAsync(CancellationToken.None);
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ public sealed class GalaxyDriverReadTests
|
||||
};
|
||||
|
||||
var readTask = driver.ReadAsync(["Silent.Tag"], CancellationToken.None);
|
||||
var finished = await Task.WhenAny(readTask, Task.Delay(TimeSpan.FromSeconds(10)));
|
||||
var finished = await Task.WhenAny(readTask, Task.Delay(TimeSpan.FromSeconds(10), TestContext.Current.CancellationToken));
|
||||
|
||||
finished.ShouldBe(readTask);
|
||||
var result = await readTask;
|
||||
|
||||
+2
-2
@@ -174,14 +174,14 @@ public sealed class GalaxyDriverShutdownTests
|
||||
driver.HasEventPumpForTests.ShouldBeTrue();
|
||||
|
||||
await sub.EmitAsync(sub.HandleByRef["Tank01.Level"], 42.0);
|
||||
(await Task.WhenAny(delivered.Task, Task.Delay(WaitMs))).ShouldBe(delivered.Task,
|
||||
(await Task.WhenAny(delivered.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(delivered.Task,
|
||||
"positive control: the stream must deliver before the shutdown");
|
||||
|
||||
await driver.ShutdownAsync(CancellationToken.None);
|
||||
|
||||
// Bounded wait, not an instantaneous IsCompleted check: the pump's dispose does not promise the
|
||||
// enumerator's cancellation registration has run by the time it returns (observed flaky).
|
||||
(await Task.WhenAny(sub.StreamCancelled.Task, Task.Delay(WaitMs))).ShouldBe(sub.StreamCancelled.Task,
|
||||
(await Task.WhenAny(sub.StreamCancelled.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(sub.StreamCancelled.Task,
|
||||
"ShutdownAsync must cancel the StreamEvents stream");
|
||||
driver.HasEventPumpForTests.ShouldBeFalse();
|
||||
driver.TrackedSubscriptionCountForTests.ShouldBe(0, "handles died with the session; the host re-subscribes after re-init");
|
||||
|
||||
+4
-4
@@ -53,7 +53,7 @@ public sealed class GatewayGalaxyAlarmFeedTests
|
||||
};
|
||||
feed.Start();
|
||||
|
||||
(await Task.WhenAny(got3.Task, Task.Delay(TimeSpan.FromSeconds(2))))
|
||||
(await Task.WhenAny(got3.Task, Task.Delay(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken)))
|
||||
.ShouldBe(got3.Task, "snapshot + transition should dispatch within 2s");
|
||||
|
||||
observed.Count.ShouldBe(3);
|
||||
@@ -109,7 +109,7 @@ public sealed class GatewayGalaxyAlarmFeedTests
|
||||
};
|
||||
feed.Start();
|
||||
|
||||
(await Task.WhenAny(got2.Task, Task.Delay(TimeSpan.FromSeconds(2)))).ShouldBe(got2.Task);
|
||||
(await Task.WhenAny(got2.Task, Task.Delay(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken))).ShouldBe(got2.Task);
|
||||
|
||||
observed[0].TransitionKind.ShouldBe(GalaxyAlarmTransitionKind.Clear);
|
||||
observed[0].IsRestatement.ShouldBeTrue();
|
||||
@@ -145,7 +145,7 @@ public sealed class GatewayGalaxyAlarmFeedTests
|
||||
};
|
||||
feed.Start();
|
||||
|
||||
(await Task.WhenAny(gotOne.Task, Task.Delay(TimeSpan.FromSeconds(2))))
|
||||
(await Task.WhenAny(gotOne.Task, Task.Delay(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken)))
|
||||
.ShouldBe(gotOne.Task);
|
||||
|
||||
// Only the well-formed Raise survives; the Unspecified + empty messages drop.
|
||||
@@ -187,7 +187,7 @@ public sealed class GatewayGalaxyAlarmFeedTests
|
||||
};
|
||||
feed.Start();
|
||||
|
||||
(await Task.WhenAny(gotOne.Task, Task.Delay(TimeSpan.FromSeconds(3))))
|
||||
(await Task.WhenAny(gotOne.Task, Task.Delay(TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken)))
|
||||
.ShouldBe(gotOne.Task, "the feed should reopen the stream and deliver after a fault");
|
||||
|
||||
calls.ShouldBeGreaterThanOrEqualTo(2);
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ public sealed class ReconnectSupervisorCycleCtsTests
|
||||
// Positive control: a cycle parked inside reopen still holds its CTS.
|
||||
Volatile.Write(ref hold[0], true);
|
||||
sup.ReportTransportFailure(new IOException("drop 3"));
|
||||
(await Task.WhenAny(reopenEntered.Task, Task.Delay(WaitMs))).ShouldBe(reopenEntered.Task);
|
||||
(await Task.WhenAny(reopenEntered.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(reopenEntered.Task);
|
||||
sup.CyclesStarted.ShouldBe(4);
|
||||
sup.CyclesReleased.ShouldBe(3, "an in-flight cycle's CTS is live until its loop exits");
|
||||
|
||||
@@ -71,10 +71,10 @@ public sealed class ReconnectSupervisorCycleCtsTests
|
||||
options: FastBackoff());
|
||||
|
||||
sup.ReportTransportFailure(new IOException("drop"));
|
||||
(await Task.WhenAny(reopenEntered.Task, Task.Delay(WaitMs))).ShouldBe(reopenEntered.Task);
|
||||
(await Task.WhenAny(reopenEntered.Task, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(reopenEntered.Task);
|
||||
|
||||
var stop = sup.StopAsync();
|
||||
(await Task.WhenAny(stop, Task.Delay(WaitMs))).ShouldBe(stop, "StopAsync must cancel the parked reopen and return");
|
||||
(await Task.WhenAny(stop, Task.Delay(WaitMs, TestContext.Current.CancellationToken))).ShouldBe(stop, "StopAsync must cancel the parked reopen and return");
|
||||
sup.CyclesReleased.ShouldBe(1);
|
||||
await Should.NotThrowAsync(sup.StopAsync); // idempotent
|
||||
Should.NotThrow(sup.Dispose);
|
||||
|
||||
Reference in New Issue
Block a user