diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSubscribeTests.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSubscribeTests.cs index 95ba88dc..d2bd8256 100644 --- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSubscribeTests.cs +++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSubscribeTests.cs @@ -995,11 +995,13 @@ public sealed class MTConnectSubscribeTests client.SampleCallCount.ShouldBe(3); } - private static async Task WaitForReconnectAttemptsAboveAsync(MTConnectDriver driver, int floor) + private static async Task WaitForReconnectAttemptsAboveAsync(MTConnectDriver driver, int floor, CancellationToken ct) { + using var watchdog = CancellationTokenSource.CreateLinkedTokenSource(ct); + watchdog.CancelAfter(Watchdog); while (driver.ReconnectAttempts <= floor) { - await Task.Delay(5).ConfigureAwait(false); + await Task.Delay(5, watchdog.Token).ConfigureAwait(false); } } @@ -1027,7 +1029,7 @@ public sealed class MTConnectSubscribeTests // call fails, and `early` may have been read late (already past the 6th call) under load, // so a call-count barrier can observe the counter unchanged. The failure is sticky, so a // working backoff keeps growing it; a frozen one never satisfies this within the watchdog. - await WaitForReconnectAttemptsAboveAsync(driver, early).WaitAsync(Watchdog, Ct); + await WaitForReconnectAttemptsAboveAsync(driver, early, Ct); early.ShouldBeGreaterThanOrEqualTo(2); driver.ReconnectAttempts.ShouldBeGreaterThan(early); @@ -1081,7 +1083,7 @@ public sealed class MTConnectSubscribeTests // call fails, and `early` may have been read late (already past the 6th call) under load, // so a call-count barrier can observe the counter unchanged. The failure is sticky, so a // working backoff keeps growing it; a frozen one never satisfies this within the watchdog. - await WaitForReconnectAttemptsAboveAsync(driver, early).WaitAsync(Watchdog, Ct); + await WaitForReconnectAttemptsAboveAsync(driver, early, Ct); early.ShouldBeGreaterThanOrEqualTo(2); driver.ReconnectAttempts.ShouldBeGreaterThan(early);