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:
@@ -739,7 +739,7 @@ public sealed class ScriptedAlarmEngineTests
|
||||
|
||||
up.Push("Temp", 150);
|
||||
|
||||
var winner = await Task.WhenAny(ackDone.Task, Task.Delay(TimeSpan.FromSeconds(3)));
|
||||
var winner = await Task.WhenAny(ackDone.Task, Task.Delay(TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken));
|
||||
winner.ShouldBe(ackDone.Task,
|
||||
"subscriber re-entering the engine must not deadlock against _evalGate");
|
||||
await ackDone.Task; // surface any inner exception
|
||||
@@ -753,7 +753,7 @@ public sealed class ScriptedAlarmEngineTests
|
||||
|
||||
/// <summary>Verifies that OnEvent emission occurs after the evaluation gate is released, so subscribers can re-enter the engine without deadlocking (regression for Core.ScriptedAlarms-003).</summary>
|
||||
[Fact]
|
||||
public void OnEvent_emission_happens_outside_evalGate(/* -003 */)
|
||||
public async Task OnEvent_emission_happens_outside_evalGate(/* -003 */)
|
||||
{
|
||||
// Direct white-box check on the gate-release ordering: AcknowledgeAsync
|
||||
// emits the Acknowledged event AFTER releasing the gate. We assert that
|
||||
@@ -764,8 +764,8 @@ public sealed class ScriptedAlarmEngineTests
|
||||
var eng = Build(up, out _);
|
||||
try
|
||||
{
|
||||
eng.LoadAsync([Alarm("HighTemp", """return (int)ctx.GetTag("Temp").Value > 100;""")],
|
||||
TestContext.Current.CancellationToken).GetAwaiter().GetResult();
|
||||
await eng.LoadAsync([Alarm("HighTemp", """return (int)ctx.GetTag("Temp").Value > 100;""")],
|
||||
TestContext.Current.CancellationToken);
|
||||
// Drive to Active so Acknowledge has something to ack.
|
||||
up.Push("Temp", 150);
|
||||
// Use the same WaitForAsync that other tests use — synchronously
|
||||
@@ -796,8 +796,7 @@ public sealed class ScriptedAlarmEngineTests
|
||||
}
|
||||
};
|
||||
|
||||
eng.AcknowledgeAsync("HighTemp", "alice", null, CancellationToken.None)
|
||||
.GetAwaiter().GetResult();
|
||||
await eng.AcknowledgeAsync("HighTemp", "alice", null, CancellationToken.None);
|
||||
|
||||
gateFreeInsideEmission.ShouldBeTrue(
|
||||
"_evalGate must be released before OnEvent fires so subscribers " +
|
||||
@@ -844,7 +843,7 @@ public sealed class ScriptedAlarmEngineTests
|
||||
// Verify Dispose does NOT complete immediately — it should block waiting
|
||||
// for the in-flight task. Without the -006 fix Dispose returns straight
|
||||
// away and the background reevaluation can outlive the engine.
|
||||
var prematureFinish = await Task.WhenAny(disposeTask, Task.Delay(200));
|
||||
var prematureFinish = await Task.WhenAny(disposeTask, Task.Delay(200, TestContext.Current.CancellationToken));
|
||||
prematureFinish.ShouldNotBe(disposeTask,
|
||||
"Dispose must block until in-flight background tasks complete");
|
||||
|
||||
@@ -1749,7 +1748,7 @@ public sealed class ScriptedAlarmEngineTests
|
||||
eng.InFlightCountForTest.ShouldBe(1);
|
||||
|
||||
var disposeTask = Task.Run(() => eng.Dispose(), TestContext.Current.CancellationToken);
|
||||
var raced = await Task.WhenAny(disposeTask, Task.Delay(300));
|
||||
var raced = await Task.WhenAny(disposeTask, Task.Delay(300, TestContext.Current.CancellationToken));
|
||||
raced.ShouldNotBe(disposeTask, "Dispose must not return while registered background work is still running");
|
||||
|
||||
gate.SetResult();
|
||||
|
||||
@@ -13,11 +13,6 @@ namespace ZB.MOM.WW.OtOpcUa.Core.Scripting.Tests;
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class CompiledScriptCacheTests
|
||||
{
|
||||
private sealed class CompileCountingGate
|
||||
{
|
||||
public int Count;
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the first call to GetOrCompile compiles the script and caches the evaluator.</summary>
|
||||
[Fact]
|
||||
public void First_call_compiles_and_caches()
|
||||
@@ -112,7 +107,7 @@ public sealed class CompiledScriptCacheTests
|
||||
|
||||
/// <summary>Verifies that concurrent compiles of the same source deduplicate to a single compilation.</summary>
|
||||
[Fact]
|
||||
public void Concurrent_compiles_of_the_same_source_deduplicate()
|
||||
public async Task Concurrent_compiles_of_the_same_source_deduplicate()
|
||||
{
|
||||
// LazyThreadSafetyMode.ExecutionAndPublication guarantees only one compile
|
||||
// even when multiple threads race GetOrCompile against an empty cache.
|
||||
@@ -122,13 +117,13 @@ public sealed class CompiledScriptCacheTests
|
||||
const string src = """return 99;""";
|
||||
|
||||
var tasks = Enumerable.Range(0, 20)
|
||||
.Select(_ => Task.Run(() => cache.GetOrCompile(src)))
|
||||
.Select(_ => Task.Run(() => cache.GetOrCompile(src), TestContext.Current.CancellationToken))
|
||||
.ToArray();
|
||||
Task.WhenAll(tasks).GetAwaiter().GetResult();
|
||||
var evaluators = await Task.WhenAll(tasks);
|
||||
|
||||
var firstInstance = tasks[0].Result;
|
||||
foreach (var t in tasks)
|
||||
ReferenceEquals(t.Result, firstInstance).ShouldBeTrue();
|
||||
var firstInstance = evaluators[0];
|
||||
foreach (var e in evaluators)
|
||||
ReferenceEquals(e, firstInstance).ShouldBeTrue();
|
||||
cache.Count.ShouldBe(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user