Skip to content

Commit 1f8b39b

Browse files
committed
fix(json-cppagent-tests): wrap Assert.Throws sync lambdas with (Action) cast for NUnit 4 (CS0121)
Cascade rebase of chore/nunit-4-upgrade onto master post-TrakHound#221 surfaced four fresh CS0121 ambiguity errors in JsonConditionsArrayShapeTests (added by TrakHound#221) where bare `() =>` lambdas passed to Assert.Throws<T> are ambiguous between the TestDelegate and Action overloads once NUnit is upgraded to 4.x. TestDelegate is obsolete-as-error in NUnit 4, so apply the same (Action) cast pattern established for the campaign in ae03e24 (AgentUuidValidationTests) at the four new sites: Streams/JsonConditionsArrayShapeTests.cs L428, L498, L516, L530
1 parent ae03e24 commit 1f8b39b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonConditionsArrayShapeTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ public void Deserialize_legacy_v1_object_keyed_shape_throws_JsonException()
425425
"\"Normal\":[{\"dataItemId\":\"n1\"}]," +
426426
"\"Unavailable\":[{\"dataItemId\":\"u1\"}]}";
427427

428-
Assert.Throws<JsonException>(() =>
429-
JsonSerializer.Deserialize<JsonConditions>(legacyV1));
428+
Assert.Throws<JsonException>((Action)(() =>
429+
JsonSerializer.Deserialize<JsonConditions>(legacyV1)));
430430
}
431431

432432
/// <summary>
@@ -495,7 +495,7 @@ public void Deserialize_unknown_level_property_is_silently_ignored()
495495
[TestCase("false")]
496496
public void Deserialize_non_array_root_throws_JsonException(string wire)
497497
{
498-
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<JsonConditions>(wire));
498+
Assert.Throws<JsonException>((Action)(() => JsonSerializer.Deserialize<JsonConditions>(wire)));
499499
}
500500

501501
/// <summary>
@@ -513,7 +513,7 @@ public void Deserialize_non_array_root_throws_JsonException(string wire)
513513
[TestCase("[[]]")]
514514
public void Deserialize_scalar_or_array_element_throws_JsonException(string wire)
515515
{
516-
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<JsonConditions>(wire));
516+
Assert.Throws<JsonException>((Action)(() => JsonSerializer.Deserialize<JsonConditions>(wire)));
517517
}
518518

519519
/// <summary>
@@ -527,7 +527,7 @@ public void Deserialize_scalar_or_array_element_throws_JsonException(string wire
527527
[TestCase("not-json-at-all")]
528528
public void Deserialize_malformed_wire_throws_JsonException(string wire)
529529
{
530-
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<JsonConditions>(wire));
530+
Assert.Throws<JsonException>((Action)(() => JsonSerializer.Deserialize<JsonConditions>(wire)));
531531
}
532532

533533
/// <summary>

0 commit comments

Comments
 (0)