Skip to content

Commit 8279b01

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 dacdc02 commit 8279b01

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tests/MTConnect.NET-Common-Tests/V2_6_V2_7/V2_7DataItemTypeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void V2_7_DataItem_constructs_with_correct_metadata(
4949
// surfaces as a clear NUnit failure with the offending type name
5050
// rather than a bare MissingMethodException.
5151
object? instance = null;
52-
Assert.DoesNotThrow(() => instance = Activator.CreateInstance(dataItemType),
52+
Assert.DoesNotThrow((Action)(() => instance = Activator.CreateInstance(dataItemType)),
5353
$"{dataItemType.Name} should have a public parameterless constructor");
5454
Assert.That(instance, Is.Not.Null);
5555
Assert.That(instance, Is.InstanceOf<DataItem>());

0 commit comments

Comments
 (0)