Skip to content

Commit 796b55d

Browse files
committed
test: cast Assert.DoesNotThrow / Throws delegates to (Action) for NUnit 4
NUnit 4's Assert.DoesNotThrow / Assert.Throws<T> resolve delegate arguments against multiple overloads (Action, TestDelegate, AsyncTestDelegate). A bare () => lambda triggers CS0121 overload ambiguity once TrakHound#239 lands the NUnit 4 upgrade. The (Action) cast disambiguates unambiguously in both NUnit 3 and 4, so the wrap is safe to land on this branch before TrakHound#239 merges. Fixes cross-PR bug class discovered on integration/up-to-pr-249 build (158 errors, 112 CS0121 across 9 test files on 7 PRs). Per-PR fix — each affected PR wraps its own new test sites so the class stays clean across the train.
1 parent 3a77c59 commit 796b55d

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tests/MTConnect.NET-Common-Tests/Agents/AgentUuidValidationTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,15 +601,15 @@ public void Warn_delegate_emits_persisted_warn_only_when_override_null_and_persi
601601
[Test]
602602
public void Null_warn_delegate_does_not_throw_on_either_rejection_path()
603603
{
604-
Assert.DoesNotThrow(() =>
604+
Assert.DoesNotThrow((Action)(() =>
605605
{
606606
_ = AgentUuidResolver.Resolve(
607607
operatorSuppliedUuid: "not-a-uuid",
608608
persistedUuid: "also-not-a-uuid",
609609
agentName: "test-agent",
610610
hostname: "test-host",
611611
warn: null);
612-
});
612+
}));
613613
}
614614

615615
/// <summary>
@@ -620,14 +620,14 @@ public void Null_warn_delegate_does_not_throw_on_either_rejection_path()
620620
[Test]
621621
public void Default_warn_argument_omitted_does_not_throw()
622622
{
623-
Assert.DoesNotThrow(() =>
623+
Assert.DoesNotThrow((Action)(() =>
624624
{
625625
_ = AgentUuidResolver.Resolve(
626626
operatorSuppliedUuid: "not-a-uuid",
627627
persistedUuid: "also-not-a-uuid",
628628
agentName: "test-agent",
629629
hostname: "test-host");
630-
});
630+
}));
631631
}
632632

633633
// ------------------------------------------------------------------
@@ -1056,7 +1056,7 @@ public void Resolve_warn_on_nil_uuid_uses_broad_acceptable_wording()
10561056
public void Derive_throws_when_both_agent_name_and_hostname_are_empty(string agentName, string hostname)
10571057
{
10581058
Assert.Throws<ArgumentException>(
1059-
() => DeterministicAgentUuid.Derive(agentName, hostname, port: 0),
1059+
(Action)(() => DeterministicAgentUuid.Derive(agentName, hostname, port: 0)),
10601060
"Both seed components empty must not silently derive a fleet-wide collision UUID.");
10611061
}
10621062

0 commit comments

Comments
 (0)