From 68de2470a404bf32e640e8ed0909e7947c7b0ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Boly=C3=B3s?= Date: Wed, 19 Aug 2026 22:25:13 +0200 Subject: [PATCH 1/4] chore(tests): normalize NUnit and NUnit3TestAdapter versions across tests Prior state fragmented four test csprojs at NUnit 3.13.3 and NUnit3TestAdapter 4.3.1/4.5.0 while the other five sat at NUnit 3.14.0 and NUnit3TestAdapter 4.6.0. Normalizing to the highest currently-in-use versions clears the drift without changing observable behavior and sets a clean baseline for the subsequent NUnit 3 -> 4 upgrade commit. Affected projects: * tests/Compliance/MTConnect-Compliance-Tests * tests/MTConnect.NET-AgentModule-MqttRelay-Tests * tests/MTConnect.NET-JSON-Tests * tests/MTConnect.NET-JSON-cppagent-Tests The remaining five test csprojs already sat at the target versions. Full-solution build (dotnet build -p:IntegrationCoverage=true): 0 warnings, 0 errors. --- .../MTConnect-Compliance-Tests.csproj | 4 ++-- .../MTConnect.NET-AgentModule-MqttRelay-Tests.csproj | 4 ++-- .../MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj | 4 ++-- .../MTConnect.NET-JSON-cppagent-Tests.csproj | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj b/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj index 5e741def2..d2f32f301 100644 --- a/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj +++ b/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj index 6c2835679..8699e9cdd 100644 --- a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj +++ b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj @@ -8,8 +8,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj b/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj index 3c26ab6cc..35a9f7f82 100644 --- a/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj +++ b/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj b/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj index 5a39b0098..e47b7842c 100644 --- a/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj +++ b/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj @@ -10,8 +10,8 @@ - - + + From 2860a94dcb502b87b25a35e456534d33af679b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Boly=C3=B3s?= Date: Wed, 19 Aug 2026 22:32:57 +0200 Subject: [PATCH 2/4] chore(tests): upgrade NUnit 3.14.0 to 4.6.1 across all test projects NUnit 4 is the current stable line; this commit lifts every test csproj onto 4.6.1 and applies the API-surface migrations the upgrade requires. ## Package bumps All 9 test csprojs move NUnit 3.14.0 to 4.6.1: * tests/Compliance/MTConnect-Compliance-Tests * tests/MTConnect.NET-AgentModule-MqttRelay-Tests * tests/MTConnect.NET-Common-Tests * tests/MTConnect.NET-Docs-Tests * tests/MTConnect.NET-HTTP-Tests * tests/MTConnect.NET-JSON-Tests * tests/MTConnect.NET-JSON-cppagent-Tests * tests/MTConnect.NET-SHDR-Tests * tests/MTConnect.NET-XML-Tests NUnit3TestAdapter stays at 4.6.0 (adapter version tracks the adapter's own release line, not the framework version). ## Compiler-driven source migrations ### CS0121 -- delegate-overload ambiguity (84 sites, 20 files) NUnit 4 added Action / Func overloads alongside the legacy TestDelegate / ActualValueDelegate overloads for Assert.DoesNotThrow, Assert.Throws, Assert.ThrowsAsync, Assert.Multiple, and Assert.That. Lambda arguments are now ambiguous under overload resolution. Each affected call site casts the lambda to (Action) so the compiler picks the new Action overload unambiguously. Assert.That sites are cast only when the constraint is a Throws.* form (void-lambda variant); the value-returning form (Is.*) is not affected in this corpus. Where the cast introduced a bare 'Action' reference in files that only transitively imported the System namespace via other usings, 'using System;' was added. ### CS9202 -- Assert.AreEqual extension-method dispatch (3 sites, 2 files) NUnit 4 removed the classic Assert.AreEqual static method and replaced it with an extension-method shim on Assert exposed by NUnit.Framework.Legacy. The extension-method shim requires C# 14 (feature 'extensions'), which the test projects do not target. The safe migration path is ClassicAssert.AreEqual from NUnit.Framework.Legacy, which is a plain static method and works under every C# language version. Two files switch the callers accordingly and add 'using NUnit.Framework.Legacy;'. Affected: * tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs (1 site) * tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs (2 error sites; 3 total AreEqual calls in the same file swept together) ## Verification Full-solution build (dotnet build -p:IntegrationCoverage=true): 0 Warning(s) 0 Error(s) --- .../MTConnect-Compliance-Tests.csproj | 2 +- .../LastSentSequencePersisterTests.cs | 5 ++- ...ect.NET-AgentModule-MqttRelay-Tests.csproj | 2 +- .../MqttRelayLifecycleDisconnectTests.cs | 8 ++-- .../MqttRelayLifecycleStopTests.cs | 7 ++-- .../WorkerLoopExceptionLoggerTests.cs | 4 +- .../Agents/AgentMulticastIsolationTests.cs | 40 +++++++++---------- .../AgentUuidDeterministicDefaultTests.cs | 3 +- .../DeviceFinderMulticastIsolationTests.cs | 20 +++++----- .../PolymorphicLeafCoverageTests.cs | 4 +- .../Headers/HeaderVersionRegressionTests.cs | 4 +- .../MTConnect.NET-Common-Tests.csproj | 2 +- .../MqttClientMulticastIsolationTests.cs | 4 +- .../MulticastIsolationTests.cs | 10 ++--- .../RegeneratedAssetsCoverageTests.cs | 2 +- .../RegeneratedConfigurationsCoverageTests.cs | 4 +- .../RegeneratedTypesCoverageTests.cs | 6 +-- .../DeviceComponentDefaultsRegressionTests.cs | 12 +++--- .../V2_6_V2_7/V2_7DataItemTypeTests.cs | 2 +- .../MTConnect.NET-Docs-Tests.csproj | 2 +- .../RouteCheckHelpersTests.cs | 24 +++++------ .../MTConnect.NET-HTTP-Tests.csproj | 2 +- .../HttpServerMulticastIsolationTests.cs | 8 ++-- .../MTConnect.NET-JSON-Tests.csproj | 2 +- .../MTConnect.NET-JSON-cppagent-Tests.csproj | 2 +- .../Streams/JsonConditionsArrayShapeTests.cs | 29 +++++++------- .../JsonSampleValueConverterEdgeCaseTests.cs | 3 +- .../JsonSampleValueToObservationTests.cs | 3 +- .../MTConnect.NET-SHDR-Tests.csproj | 2 +- .../ShdrMulticastIsolationTests.cs | 6 +-- .../MTConnect.NET-XML-Tests.csproj | 2 +- .../XmlStreamsResponseDocumentTests.cs | 5 ++- 32 files changed, 119 insertions(+), 112 deletions(-) diff --git a/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj b/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj index d2f32f301..c4fc68db8 100644 --- a/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj +++ b/tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/LastSentSequencePersisterTests.cs b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/LastSentSequencePersisterTests.cs index 7fccbc448..c55fa0fd2 100644 --- a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/LastSentSequencePersisterTests.cs +++ b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/LastSentSequencePersisterTests.cs @@ -2,6 +2,7 @@ // TrakHound Inc. licenses this file to you under the MIT license. using NUnit.Framework; +using System; namespace MTConnect.AgentModule.MqttRelay.Tests { @@ -90,7 +91,7 @@ public void TryFlush_keeps_dirty_when_writer_throws() persister.Update(123UL); Assert.Throws( - () => persister.TryFlush(_ => throw new System.IO.IOException("disk full"))); + (Action)(() => persister.TryFlush(_ => throw new System.IO.IOException("disk full")))); Assert.That(persister.IsDirty, Is.True, "A failed write must leave the persister dirty so the next flush retries."); @@ -135,7 +136,7 @@ public void TryFlush_no_ops_when_writer_is_null() // A null writer means the caller has not wired persistence // (e.g. DurableRelay disabled at runtime); the persister // must not throw. - Assert.DoesNotThrow(() => persister.TryFlush(null)); + Assert.DoesNotThrow((Action)(() => persister.TryFlush(null))); // Dirty bit unchanged because no write happened. Assert.That(persister.IsDirty, Is.True); } diff --git a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj index 8699e9cdd..8859d5f72 100644 --- a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj +++ b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj @@ -8,7 +8,7 @@ - + all diff --git a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleDisconnectTests.cs b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleDisconnectTests.cs index d2611d524..56184d2cb 100644 --- a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleDisconnectTests.cs +++ b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleDisconnectTests.cs @@ -89,10 +89,10 @@ public void DisconnectWithTimeout_does_not_throw_when_disconnect_factory_throws_ // and route the exception to the fault logger. string loggedFault = null; - Assert.DoesNotThrow(() => MqttRelayLifecycle.DisconnectWithTimeout( + Assert.DoesNotThrow((Action)(() => MqttRelayLifecycle.DisconnectWithTimeout( disconnect: () => throw new InvalidOperationException("sync throw"), timeout: TimeSpan.FromSeconds(1), - onFault: ex => loggedFault = ex.Message)); + onFault: ex => loggedFault = ex.Message))); Assert.That(loggedFault, Is.EqualTo("sync throw")); } @@ -104,10 +104,10 @@ public void DisconnectWithTimeout_no_ops_when_disconnect_factory_is_null() // The shutdown path must tolerate a null disconnect factory // (for example when _mqttClient is null because the worker // never ran). - Assert.DoesNotThrow(() => MqttRelayLifecycle.DisconnectWithTimeout( + Assert.DoesNotThrow((Action)(() => MqttRelayLifecycle.DisconnectWithTimeout( disconnect: null, timeout: TimeSpan.FromSeconds(1), - onFault: _ => { })); + onFault: _ => { }))); } } } diff --git a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleStopTests.cs b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleStopTests.cs index 061d132ea..05d59af5b 100644 --- a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleStopTests.cs +++ b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleStopTests.cs @@ -2,6 +2,7 @@ // TrakHound Inc. licenses this file to you under the MIT license. using NUnit.Framework; +using System; namespace MTConnect.AgentModule.MqttRelay.Tests { @@ -32,7 +33,7 @@ public void StopServers_does_not_throw_when_both_servers_null() // either server is the worst case; the helper must be a // total function over (null, null). Assert.DoesNotThrow( - () => MqttRelayLifecycle.StopServers(documentStop: null, entityStop: null)); + (Action)(() => MqttRelayLifecycle.StopServers(documentStop: null, entityStop: null))); } /// Pins the behaviour expressed by the test name: stop servers invokes document stop when provided. @@ -85,9 +86,9 @@ public void StopServers_swallows_document_stop_exception_and_runs_entity_stop() // shutdown leaks live handlers. var entityStopped = false; - Assert.DoesNotThrow(() => MqttRelayLifecycle.StopServers( + Assert.DoesNotThrow((Action)(() => MqttRelayLifecycle.StopServers( documentStop: () => throw new System.InvalidOperationException("doc"), - entityStop: () => entityStopped = true)); + entityStop: () => entityStopped = true))); Assert.That(entityStopped, Is.True); } diff --git a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/WorkerLoopExceptionLoggerTests.cs b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/WorkerLoopExceptionLoggerTests.cs index 093b158ee..7c2070fe8 100644 --- a/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/WorkerLoopExceptionLoggerTests.cs +++ b/tests/MTConnect.NET-AgentModule-MqttRelay-Tests/WorkerLoopExceptionLoggerTests.cs @@ -95,9 +95,9 @@ public void Log_no_ops_when_callback_is_null() // Defensive: the helper must not throw when the logger is // not wired (would defeat the purpose of catching the // unexpected exception). - Assert.DoesNotThrow(() => WorkerLoopExceptionLogger.Log( + Assert.DoesNotThrow((Action)(() => WorkerLoopExceptionLogger.Log( exception: new InvalidOperationException("boom"), - onLog: null)); + onLog: null))); } /// Pins the behaviour expressed by the test name: log treats subclass of task canceled exception as cancellation. diff --git a/tests/MTConnect.NET-Common-Tests/Agents/AgentMulticastIsolationTests.cs b/tests/MTConnect.NET-Common-Tests/Agents/AgentMulticastIsolationTests.cs index 71d570b2f..de51690f6 100644 --- a/tests/MTConnect.NET-Common-Tests/Agents/AgentMulticastIsolationTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Agents/AgentMulticastIsolationTests.cs @@ -65,7 +65,7 @@ public void Agent_DeviceAdded_NullInternalErrorSwallowsFault() var device = new Device { Name = "device-1", Uuid = "uuid-1" }; EventHandler handler = (_, _) => throw new InvalidOperationException("DeviceAdded fault"); - Assert.DoesNotThrow(() => handler.Raise(this, (IDevice)device, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IDevice)device, null))); } // ----------------------------------------------------------------------- @@ -96,7 +96,7 @@ public void Agent_ObservationReceived_NullInternalErrorSwallowsFault() var obs = new ObservationInput(); EventHandler handler = (_, _) => throw new InvalidOperationException("ObservationReceived fault"); - Assert.DoesNotThrow(() => handler.Raise(this, (IObservationInput)obs, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IObservationInput)obs, null))); } // ----------------------------------------------------------------------- @@ -127,7 +127,7 @@ public void Agent_ObservationAdded_NullInternalErrorSwallowsFault() var obs = new Observation(); EventHandler handler = (_, _) => throw new InvalidOperationException("ObservationAdded fault"); - Assert.DoesNotThrow(() => handler.Raise(this, (IObservation)obs, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IObservation)obs, null))); } // ----------------------------------------------------------------------- @@ -158,7 +158,7 @@ public void Agent_AssetAdded_NullInternalErrorSwallowsFault() var asset = new Asset { AssetId = "a1", Timestamp = DateTime.UtcNow }; EventHandler handler = (_, _) => throw new InvalidOperationException("AssetAdded fault"); - Assert.DoesNotThrow(() => handler.Raise(this, (IAsset)asset, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IAsset)asset, null))); } // ----------------------------------------------------------------------- @@ -187,7 +187,7 @@ public void AgentBroker_StreamsResponseSent_NullInternalErrorSwallowsFault() { EventHandler handler = (_, _) => throw new InvalidOperationException("StreamsResponseSent fault"); - Assert.DoesNotThrow(() => handler.Raise(this, EventArgs.Empty, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, EventArgs.Empty, null))); } // ----------------------------------------------------------------------- @@ -201,7 +201,7 @@ public void Agent_NullGenericHandler_DoesNotThrow() EventHandler? handler = null; var device = new Device { Name = "noop-device", Uuid = "noop-uuid" }; - Assert.DoesNotThrow(() => handler.Raise(this, (IDevice)device, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IDevice)device, null))); } /// Pins the behavior expressed by the test name: Raise with a null non-generic EventHandler is a safe no-op covering the no-subscriber case at runtime. @@ -210,7 +210,7 @@ public void AgentBroker_NullNonGenericHandler_DoesNotThrow() { EventHandler? handler = null; - Assert.DoesNotThrow(() => handler.Raise(this, EventArgs.Empty, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, EventArgs.Empty, null))); } // ======================================================================= @@ -246,7 +246,7 @@ public void Agent_InvalidDeviceAdded_NullInternalErrorSwallowsFault() var result = new ValidationResult(false, "bad device"); MTConnectDeviceValidationHandler handler = (_, _) => throw new InvalidOperationException("InvalidDeviceAdded fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(device, result))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(device, result)))); } // ----------------------------------------------------------------------- @@ -278,7 +278,7 @@ public void Agent_InvalidComponentAdded_NullInternalErrorSwallowsFault() var result = new ValidationResult(false, "bad component"); MTConnectComponentValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidComponentAdded fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", component, result))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", component, result)))); } // ----------------------------------------------------------------------- @@ -310,7 +310,7 @@ public void Agent_InvalidCompositionAdded_NullInternalErrorSwallowsFault() var result = new ValidationResult(false, "bad composition"); MTConnectCompositionValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidCompositionAdded fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", composition, result))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", composition, result)))); } // ----------------------------------------------------------------------- @@ -342,7 +342,7 @@ public void Agent_InvalidDataItemAdded_NullInternalErrorSwallowsFault() var result = new ValidationResult(false, "bad data item"); MTConnectDataItemValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidDataItemAdded fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", dataItem, result))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", dataItem, result)))); } // ----------------------------------------------------------------------- @@ -372,7 +372,7 @@ public void Agent_InvalidObservationAdded_NullInternalErrorSwallowsFault() var result = new ValidationResult(false, "bad observation"); MTConnectObservationValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidObservationAdded fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", "key-1", result))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", "key-1", result)))); } // ----------------------------------------------------------------------- @@ -404,7 +404,7 @@ public void Agent_InvalidAssetAdded_NullInternalErrorSwallowsFault() var result = new ValidationResult(false, "bad asset"); MTConnectAssetValidationHandler handler = (_, _) => throw new InvalidOperationException("InvalidAssetAdded fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(asset, result))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(asset, result)))); } // ======================================================================= @@ -435,7 +435,7 @@ public void AgentBroker_DevicesRequestReceived_NullInternalErrorSwallowsFault() { MTConnectDevicesRequestedHandler handler = _ => throw new InvalidOperationException("DevicesRequestReceived fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1"))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1")))); } // ----------------------------------------------------------------------- @@ -462,7 +462,7 @@ public void AgentBroker_DevicesResponseSent_NullInternalErrorSwallowsFault() { MTConnectDevicesHandler handler = _ => throw new InvalidOperationException("DevicesResponseSent fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(null!))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(null!)))); } // ----------------------------------------------------------------------- @@ -489,7 +489,7 @@ public void AgentBroker_StreamsRequestReceived_NullInternalErrorSwallowsFault() { MTConnectStreamsRequestedHandler handler = _ => throw new InvalidOperationException("StreamsRequestReceived fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1"))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1")))); } // ----------------------------------------------------------------------- @@ -518,7 +518,7 @@ public void AgentBroker_AssetsRequestReceived_NullInternalErrorSwallowsFault() var ids = new[] { "asset-1" }; MTConnectAssetsRequestedHandler handler = _ => throw new InvalidOperationException("AssetsRequestReceived fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(ids))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(ids)))); } // ----------------------------------------------------------------------- @@ -545,7 +545,7 @@ public void AgentBroker_DeviceAssetsRequestReceived_NullInternalErrorSwallowsFau { MTConnectDeviceAssetsRequestedHandler handler = _ => throw new InvalidOperationException("DeviceAssetsRequestReceived fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1"))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1")))); } // ----------------------------------------------------------------------- @@ -572,7 +572,7 @@ public void AgentBroker_AssetsResponseSent_NullInternalErrorSwallowsFault() { MTConnectAssetsHandler handler = _ => throw new InvalidOperationException("AssetsResponseSent fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(null!))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(null!)))); } // ----------------------------------------------------------------------- @@ -599,7 +599,7 @@ public void AgentBroker_ErrorResponseSent_NullInternalErrorSwallowsFault() { MTConnectErrorHandler handler = _ => throw new InvalidOperationException("ErrorResponseSent fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h((IErrorResponseDocument)null!))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h((IErrorResponseDocument)null!)))); } } } diff --git a/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs b/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs index a38c16877..714ddcc68 100644 --- a/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs @@ -6,6 +6,7 @@ using MTConnect.Agents; using MTConnect.Configurations; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace MTConnect.Tests.Common.Agents { @@ -123,7 +124,7 @@ private static string SimulateFreshBoot(string agentName, int port = 0) public void DeriveFromSeed_matches_python_uuid_v5_NAMESPACE_DNS_example_com_vector() { var derived = DeterministicAgentUuid.DeriveFromSeed("example.com"); - Assert.AreEqual("cfbff0d1-9375-5685-968c-48ce8b15ae17", derived, + ClassicAssert.AreEqual("cfbff0d1-9375-5685-968c-48ce8b15ae17", derived, "DeriveFromSeed must reproduce the canonical UUID v5(NAMESPACE_DNS, 'example.com') vector."); } diff --git a/tests/MTConnect.NET-Common-Tests/DeviceFinderMulticastIsolationTests.cs b/tests/MTConnect.NET-Common-Tests/DeviceFinderMulticastIsolationTests.cs index ae37ba301..6cd646595 100644 --- a/tests/MTConnect.NET-Common-Tests/DeviceFinderMulticastIsolationTests.cs +++ b/tests/MTConnect.NET-Common-Tests/DeviceFinderMulticastIsolationTests.cs @@ -86,7 +86,7 @@ public void DeviceFinder_DeviceFound_NullInternalErrorSwallowsFault() { TestDeviceHandler handler = (_, _) => throw new InvalidOperationException("DeviceFound fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(this, "device-1"))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(this, "device-1")))); } // ----------------------------------------------------------------------- @@ -113,7 +113,7 @@ public void DeviceFinder_SearchCompleted_NullInternalErrorSwallowsFault() { TestRequestStatusHandler handler = (_, _) => throw new InvalidOperationException("SearchCompleted fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(this, 0L))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(this, 0L)))); } // ----------------------------------------------------------------------- @@ -141,7 +141,7 @@ public void DeviceFinder_PingSent_NullInternalErrorSwallowsFault() { TestPingSentHandlerOnFinder handler = (_, _) => throw new InvalidOperationException("PingSent fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback)))); } // ----------------------------------------------------------------------- @@ -169,7 +169,7 @@ public void DeviceFinder_PingReceived_NullInternalErrorSwallowsFault() { TestPingReceivedHandlerOnFinder handler = (_, _, _) => throw new InvalidOperationException("PingReceived fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback, null!))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback, null!)))); } // ----------------------------------------------------------------------- @@ -196,7 +196,7 @@ public void DeviceFinder_PortRequest_NullInternalErrorSwallowsFault() { TestPortRequestHandler handler = (_, _, _) => throw new InvalidOperationException("PortRequest fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback, 5000))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback, 5000)))); } // ----------------------------------------------------------------------- @@ -223,7 +223,7 @@ public void DeviceFinder_ProbeRequest_NullInternalErrorSwallowsFault() { TestProbeRequestHandler handler = (_, _, _) => throw new InvalidOperationException("ProbeRequest fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback, 5000))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(this, IPAddress.Loopback, 5000)))); } // ----------------------------------------------------------------------- @@ -251,7 +251,7 @@ public void PingQueue_PingSent_NullInternalErrorSwallowsFault() { TestPingSentHandlerOnQueue handler = _ => throw new InvalidOperationException("PingQueue.PingSent fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(IPAddress.Loopback))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(IPAddress.Loopback)))); } // ----------------------------------------------------------------------- @@ -279,7 +279,7 @@ public void PingQueue_PingReceived_NullInternalErrorSwallowsFault() { TestPingReceivedHandlerOnQueue handler = (_, _) => throw new InvalidOperationException("PingQueue.PingReceived fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(IPAddress.Loopback, null!))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(IPAddress.Loopback, null!)))); } // ----------------------------------------------------------------------- @@ -307,7 +307,7 @@ public void PingQueue_Completed_NullInternalErrorSwallowsFault() { TestCompletedHandler handler = _ => throw new InvalidOperationException("PingQueue.Completed fault"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(new List()))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(new List())))); } // ----------------------------------------------------------------------- @@ -320,7 +320,7 @@ public void DeviceFinder_NullCustomDelegateHandler_DoesNotThrow() { TestDeviceHandler? handler = null; - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler!, h => h(this, "any"))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler!, h => h(this, "any")))); } } } diff --git a/tests/MTConnect.NET-Common-Tests/Devices/Configurations/PolymorphicLeafCoverageTests.cs b/tests/MTConnect.NET-Common-Tests/Devices/Configurations/PolymorphicLeafCoverageTests.cs index 3ac63fdc9..ef57c53f8 100644 --- a/tests/MTConnect.NET-Common-Tests/Devices/Configurations/PolymorphicLeafCoverageTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Devices/Configurations/PolymorphicLeafCoverageTests.cs @@ -114,7 +114,7 @@ public void Simple_leaf_constructs_via_parameterless_ctor( Type simpleType, Type abstractInterface, Type simpleInterface) { object? instance = null; - Assert.DoesNotThrow(() => instance = Activator.CreateInstance(simpleType), + Assert.DoesNotThrow((Action)(() => instance = Activator.CreateInstance(simpleType)), $"{simpleType.Name} must have a public parameterless ctor"); Assert.That(instance, Is.Not.Null); } @@ -146,7 +146,7 @@ public void DataSet_leaf_constructs_via_parameterless_ctor( Type dataSetType, Type abstractInterface, Type simpleInterface, Type dataSetInterface) { object? instance = null; - Assert.DoesNotThrow(() => instance = Activator.CreateInstance(dataSetType), + Assert.DoesNotThrow((Action)(() => instance = Activator.CreateInstance(dataSetType)), $"{dataSetType.Name} must have a public parameterless ctor"); Assert.That(instance, Is.Not.Null); } diff --git a/tests/MTConnect.NET-Common-Tests/Headers/HeaderVersionRegressionTests.cs b/tests/MTConnect.NET-Common-Tests/Headers/HeaderVersionRegressionTests.cs index 1d9ba6afe..da27942b1 100644 --- a/tests/MTConnect.NET-Common-Tests/Headers/HeaderVersionRegressionTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Headers/HeaderVersionRegressionTests.cs @@ -144,7 +144,7 @@ public void No_response_envelope_emits_the_library_assembly_version() var assets = broker.GetAssetsResponseDocument(); var error = broker.GetErrorResponseDocument(ErrorCode.UNSUPPORTED, "test"); - Assert.Multiple(() => + Assert.Multiple((Action)(() => { Assert.That(devices!.Header.Version, Is.Not.EqualTo(libraryVersion), "Devices Header.version must not echo the library assembly version."); @@ -152,7 +152,7 @@ public void No_response_envelope_emits_the_library_assembly_version() "Assets Header.version must not echo the library assembly version."); Assert.That(error!.Header.Version, Is.Not.EqualTo(libraryVersion), "Error Header.version must not echo the library assembly version."); - }); + })); } } } diff --git a/tests/MTConnect.NET-Common-Tests/MTConnect.NET-Common-Tests.csproj b/tests/MTConnect.NET-Common-Tests/MTConnect.NET-Common-Tests.csproj index 1b09a0fdd..d65bb5270 100644 --- a/tests/MTConnect.NET-Common-Tests/MTConnect.NET-Common-Tests.csproj +++ b/tests/MTConnect.NET-Common-Tests/MTConnect.NET-Common-Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/tests/MTConnect.NET-Common-Tests/MqttClientMulticastIsolationTests.cs b/tests/MTConnect.NET-Common-Tests/MqttClientMulticastIsolationTests.cs index 90a9bf0e0..1ae71ebc0 100644 --- a/tests/MTConnect.NET-Common-Tests/MqttClientMulticastIsolationTests.cs +++ b/tests/MTConnect.NET-Common-Tests/MqttClientMulticastIsolationTests.cs @@ -164,7 +164,7 @@ public void MqttClient_NullHandler_DoesNotThrow() EventHandler? handler = null; EventHandler? internalError = null; - Assert.DoesNotThrow(() => handler.Raise(this, "x", internalError)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, "x", internalError))); } /// Pins the behavior expressed by the test name: Raise non-generic with a null handler is a safe no-op. @@ -174,7 +174,7 @@ public void MqttClient_NullHandlerNonGeneric_DoesNotThrow() EventHandler? handler = null; EventHandler? internalError = null; - Assert.DoesNotThrow(() => handler.Raise(this, EventArgs.Empty, internalError)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, EventArgs.Empty, internalError))); } } } diff --git a/tests/MTConnect.NET-Common-Tests/MulticastIsolationTests.cs b/tests/MTConnect.NET-Common-Tests/MulticastIsolationTests.cs index a8344469b..63452817c 100644 --- a/tests/MTConnect.NET-Common-Tests/MulticastIsolationTests.cs +++ b/tests/MTConnect.NET-Common-Tests/MulticastIsolationTests.cs @@ -75,7 +75,7 @@ public void MulticastIsolation_Generic_TerminalSwallowsInternalErrorOwnThrow() internalError += (s, ex) => throw new InvalidOperationException("internal-1"); internalError += (s, ex) => throw new InvalidOperationException("internal-2"); - Assert.DoesNotThrow(() => handler.Raise(this, 0, internalError!)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, 0, internalError!))); } // --- Non-generic overload --------------------------------------------- @@ -138,7 +138,7 @@ public void MulticastIsolation_NonGeneric_TerminalSwallowsInternalErrorOwnThrow( internalError += (s, ex) => throw new InvalidOperationException("internal-1"); internalError += (s, ex) => throw new InvalidOperationException("internal-2"); - Assert.DoesNotThrow(() => handler.Raise(this, EventArgs.Empty, internalError!)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, EventArgs.Empty, internalError!))); } // --- Generic custom-delegate overload --------------------------------- @@ -204,7 +204,7 @@ public void MulticastIsolation_GenericDelegate_TerminalSwallowsInternalErrorOwnT internalError += (_, _) => throw new InvalidOperationException("internal-1"); internalError += (_, _) => throw new InvalidOperationException("internal-2"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(0), internalError!)); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(0), internalError!))); } /// Pins the behavior expressed by the test name: the generic-delegate overload accepts a null handler as a safe no-op covering the no-subscriber case. @@ -213,7 +213,7 @@ public void MulticastIsolation_GenericDelegate_NullHandler_DoesNotThrow() { CustomDelegate? handler = null; - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler!, h => h(0))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler!, h => h(0)))); } /// Pins the behavior expressed by the test name: the generic-delegate overload swallows subscriber faults at the per-delegate boundary when internalError is left at its default null. @@ -222,7 +222,7 @@ public void MulticastIsolation_GenericDelegate_NullInternalErrorSwallowsFault() { CustomDelegate handler = _ => throw new InvalidOperationException("boom"); - Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(0))); + Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(0)))); } } } diff --git a/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedAssetsCoverageTests.cs b/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedAssetsCoverageTests.cs index bbb9c5638..d823f8e51 100644 --- a/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedAssetsCoverageTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedAssetsCoverageTests.cs @@ -93,7 +93,7 @@ public void Asset_subtype_is_constructible(Type type) { object? instance = null; Assert.DoesNotThrow( - () => instance = Activator.CreateInstance(type), + (Action)(() => instance = Activator.CreateInstance(type)), $"{type.FullName} parameterless ctor threw"); Assert.That(instance, Is.Not.Null, $"{type.FullName} parameterless ctor returned null"); diff --git a/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedConfigurationsCoverageTests.cs b/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedConfigurationsCoverageTests.cs index 51e9f45d2..03966d6f2 100644 --- a/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedConfigurationsCoverageTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedConfigurationsCoverageTests.cs @@ -80,7 +80,7 @@ public void Configuration_subtype_is_constructible(Type type) { object? instance = null; Assert.DoesNotThrow( - () => instance = Activator.CreateInstance(type), + (Action)(() => instance = Activator.CreateInstance(type)), $"{type.FullName} parameterless ctor threw"); Assert.That(instance, Is.Not.Null, $"{type.FullName} parameterless ctor returned null"); @@ -111,7 +111,7 @@ public void Configuration_subtype_string_properties_round_trip(Type type) var sentinel = $"sentinel-{property.Name}"; Assert.DoesNotThrow( - () => property.SetValue(instance, sentinel), + (Action)(() => property.SetValue(instance, sentinel)), $"{type.FullName}.{property.Name} setter threw"); var readBack = property.GetValue(instance) as string; Assert.That(readBack, Is.EqualTo(sentinel), diff --git a/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedTypesCoverageTests.cs b/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedTypesCoverageTests.cs index 7c26b1c78..c6328c9ca 100644 --- a/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedTypesCoverageTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Reflection/RegeneratedTypesCoverageTests.cs @@ -219,7 +219,7 @@ public void Type_can_be_constructed(Type type) // V2_6_V2_7/. object? instance = null; Assert.DoesNotThrow( - () => instance = Activator.CreateInstance(type), + (Action)(() => instance = Activator.CreateInstance(type)), $"{type.FullName} parameterless ctor threw"); Assert.That(instance, Is.Not.Null, $"{type.FullName} parameterless ctor returned null"); @@ -255,12 +255,12 @@ public void Type_round_trips_default_property_values(Type type) object? sentinel = GetDefaultValue(property.PropertyType); Assert.DoesNotThrow( - () => property.SetValue(instance, sentinel), + (Action)(() => property.SetValue(instance, sentinel)), $"{key} setter threw for default({property.PropertyType.Name})"); object? readBack = null; Assert.DoesNotThrow( - () => readBack = property.GetValue(instance), + (Action)(() => readBack = property.GetValue(instance)), $"{key} getter threw after setting default({property.PropertyType.Name})"); // Read-back equality is only asserted on auto-properties. diff --git a/tests/MTConnect.NET-Common-Tests/Regressions/DeviceComponentDefaultsRegressionTests.cs b/tests/MTConnect.NET-Common-Tests/Regressions/DeviceComponentDefaultsRegressionTests.cs index 2822a738c..639c918e8 100644 --- a/tests/MTConnect.NET-Common-Tests/Regressions/DeviceComponentDefaultsRegressionTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Regressions/DeviceComponentDefaultsRegressionTests.cs @@ -32,12 +32,12 @@ public class DeviceComponentDefaultsRegressionTests public void Device_default_constructor_leaves_identity_fields_null() { var device = new Device(); - Assert.Multiple(() => + Assert.Multiple((Action)(() => { Assert.That(device.Id, Is.Null, "Device.Id"); Assert.That(device.Name, Is.Null, "Device.Name"); Assert.That(device.Uuid, Is.Null, "Device.Uuid"); - }); + })); } /// Pins the behaviour expressed by the test name: agent default constructor leaves identity fields null. @@ -45,12 +45,12 @@ public void Device_default_constructor_leaves_identity_fields_null() public void Agent_default_constructor_leaves_identity_fields_null() { var agent = new Agent(); - Assert.Multiple(() => + Assert.Multiple((Action)(() => { Assert.That(agent.Id, Is.Null, "Agent.Id"); Assert.That(agent.Name, Is.Null, "Agent.Name"); Assert.That(agent.Uuid, Is.Null, "Agent.Uuid"); - }); + })); } /// Pins the behaviour expressed by the test name: sequential default devices share null uuid. @@ -71,12 +71,12 @@ public void Sequential_default_Devices_share_null_Uuid() public void Object_initializer_continues_to_set_Device_identity() { var device = new Device { Id = "id-A", Name = "name-A", Uuid = "uuid-A" }; - Assert.Multiple(() => + Assert.Multiple((Action)(() => { Assert.That(device.Id, Is.EqualTo("id-A")); Assert.That(device.Name, Is.EqualTo("name-A")); Assert.That(device.Uuid, Is.EqualTo("uuid-A")); - }); + })); } // ---- Reflection guard -------------------------------------- diff --git a/tests/MTConnect.NET-Common-Tests/V2_6_V2_7/V2_7DataItemTypeTests.cs b/tests/MTConnect.NET-Common-Tests/V2_6_V2_7/V2_7DataItemTypeTests.cs index 0faef2fc1..47522eed0 100644 --- a/tests/MTConnect.NET-Common-Tests/V2_6_V2_7/V2_7DataItemTypeTests.cs +++ b/tests/MTConnect.NET-Common-Tests/V2_6_V2_7/V2_7DataItemTypeTests.cs @@ -49,7 +49,7 @@ public void V2_7_DataItem_constructs_with_correct_metadata( // surfaces as a clear NUnit failure with the offending type name // rather than a bare MissingMethodException. object? instance = null; - Assert.DoesNotThrow(() => instance = Activator.CreateInstance(dataItemType), + Assert.DoesNotThrow((Action)(() => instance = Activator.CreateInstance(dataItemType)), $"{dataItemType.Name} should have a public parameterless constructor"); Assert.That(instance, Is.Not.Null); Assert.That(instance, Is.InstanceOf()); diff --git a/tests/MTConnect.NET-Docs-Tests/MTConnect.NET-Docs-Tests.csproj b/tests/MTConnect.NET-Docs-Tests/MTConnect.NET-Docs-Tests.csproj index 4e036964f..1cb840c5b 100644 --- a/tests/MTConnect.NET-Docs-Tests/MTConnect.NET-Docs-Tests.csproj +++ b/tests/MTConnect.NET-Docs-Tests/MTConnect.NET-Docs-Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/tests/MTConnect.NET-Docs-Tests/RouteCheckHelpersTests.cs b/tests/MTConnect.NET-Docs-Tests/RouteCheckHelpersTests.cs index 7123c4d82..08aee4a9c 100644 --- a/tests/MTConnect.NET-Docs-Tests/RouteCheckHelpersTests.cs +++ b/tests/MTConnect.NET-Docs-Tests/RouteCheckHelpersTests.cs @@ -115,7 +115,7 @@ public void MdFileToRoute_WindowsSeparators_AreNormalised() public void MdFileToRoute_NullDocsRoot_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.MdFileToRoute(null!, "/repo/docs/index.md")); + (Action)(() => RouteCheckHelpers.MdFileToRoute(null!, "/repo/docs/index.md"))); Assert.That(ex!.ParamName, Is.EqualTo("docsRoot")); } @@ -127,7 +127,7 @@ public void MdFileToRoute_NullDocsRoot_Throws() public void MdFileToRoute_NullAbsPath_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.MdFileToRoute("/repo/docs", null!)); + (Action)(() => RouteCheckHelpers.MdFileToRoute("/repo/docs", null!))); Assert.That(ex!.ParamName, Is.EqualTo("absPath")); } @@ -276,7 +276,7 @@ public void CollectMarkdownFiles_NullDir_Throws() { var results = new List(); var ex = Assert.Throws( - () => RouteCheckHelpers.CollectMarkdownFiles(null!, results)); + (Action)(() => RouteCheckHelpers.CollectMarkdownFiles(null!, results))); Assert.That(ex!.ParamName, Is.EqualTo("dir")); } @@ -288,7 +288,7 @@ public void CollectMarkdownFiles_NullDir_Throws() public void CollectMarkdownFiles_NullResults_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.CollectMarkdownFiles("/tmp", null!)); + (Action)(() => RouteCheckHelpers.CollectMarkdownFiles("/tmp", null!))); Assert.That(ex!.ParamName, Is.EqualTo("results")); } @@ -300,7 +300,7 @@ public void CollectMarkdownFiles_NullResults_Throws() public void CollectRoutes_NullDocsRoot_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.CollectRoutes(null!)); + (Action)(() => RouteCheckHelpers.CollectRoutes(null!))); Assert.That(ex!.ParamName, Is.EqualTo("docsRoot")); } @@ -405,7 +405,7 @@ public void ExtractBannerPort_EmptyLog_ReturnsNull() public void ExtractBannerPort_NullLog_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.ExtractBannerPort(null!)); + (Action)(() => RouteCheckHelpers.ExtractBannerPort(null!))); Assert.That(ex!.ParamName, Is.EqualTo("log")); } @@ -459,7 +459,7 @@ public void LocateRepoRoot_NoMatch_ThrowsWithDiagnosticContext() // ancestor of the temp directory. The walk will exhaust at // the filesystem root. var ex = Assert.Throws( - () => RouteCheckHelpers.LocateRepoRoot(fixture.Path, "no-such-marker-12345.txt")); + (Action)(() => RouteCheckHelpers.LocateRepoRoot(fixture.Path, "no-such-marker-12345.txt"))); Assert.That(ex!.Message, Does.Contain(fixture.Path)); Assert.That(ex.Message, Does.Contain("ancestor")); } @@ -472,7 +472,7 @@ public void LocateRepoRoot_NoMatch_ThrowsWithDiagnosticContext() public void LocateRepoRoot_NullStartDirectory_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.LocateRepoRoot(null!, "marker.txt")); + (Action)(() => RouteCheckHelpers.LocateRepoRoot(null!, "marker.txt"))); Assert.That(ex!.ParamName, Is.EqualTo("startDirectory")); } @@ -484,7 +484,7 @@ public void LocateRepoRoot_NullStartDirectory_Throws() public void LocateRepoRoot_NullMarkerFile_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.LocateRepoRoot("/tmp", null!)); + (Action)(() => RouteCheckHelpers.LocateRepoRoot("/tmp", null!))); Assert.That(ex!.ParamName, Is.EqualTo("markerFile")); } @@ -715,7 +715,7 @@ public void ShardRoutes_AssignmentFollowsRoundRobinModulus() public void ShardRoutes_NullRoutes_Throws() { var ex = Assert.Throws( - () => RouteCheckHelpers.ShardRoutes(null!, 1, 1)); + (Action)(() => RouteCheckHelpers.ShardRoutes(null!, 1, 1))); Assert.That(ex!.ParamName, Is.EqualTo("routes")); } @@ -729,7 +729,7 @@ public void ShardRoutes_NullRoutes_Throws() public void ShardRoutes_NonPositiveTotal_Throws(int total) { var ex = Assert.Throws( - () => RouteCheckHelpers.ShardRoutes(SampleRoutes, 1, total)); + (Action)(() => RouteCheckHelpers.ShardRoutes(SampleRoutes, 1, total))); Assert.That(ex!.ParamName, Is.EqualTo("total")); } @@ -745,7 +745,7 @@ public void ShardRoutes_NonPositiveTotal_Throws(int total) public void ShardRoutes_IndexOutOfRange_Throws(int index, int total) { var ex = Assert.Throws( - () => RouteCheckHelpers.ShardRoutes(SampleRoutes, index, total)); + (Action)(() => RouteCheckHelpers.ShardRoutes(SampleRoutes, index, total))); Assert.That(ex!.ParamName, Is.EqualTo("index")); } diff --git a/tests/MTConnect.NET-HTTP-Tests/MTConnect.NET-HTTP-Tests.csproj b/tests/MTConnect.NET-HTTP-Tests/MTConnect.NET-HTTP-Tests.csproj index ec37aa305..2cf7036af 100644 --- a/tests/MTConnect.NET-HTTP-Tests/MTConnect.NET-HTTP-Tests.csproj +++ b/tests/MTConnect.NET-HTTP-Tests/MTConnect.NET-HTTP-Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/tests/MTConnect.NET-HTTP-Tests/Servers/HttpServerMulticastIsolationTests.cs b/tests/MTConnect.NET-HTTP-Tests/Servers/HttpServerMulticastIsolationTests.cs index e01683d1a..7d9505aa7 100644 --- a/tests/MTConnect.NET-HTTP-Tests/Servers/HttpServerMulticastIsolationTests.cs +++ b/tests/MTConnect.NET-HTTP-Tests/Servers/HttpServerMulticastIsolationTests.cs @@ -57,7 +57,7 @@ public void HttpResponseHandler_ResponseSent_NullInternalErrorSwallowsFault() var response = new MTConnectHttpResponse { ContentType = "application/xml" }; EventHandler handler = (_, _) => throw new InvalidOperationException("ResponseSent fault"); - Assert.DoesNotThrow(() => handler.Raise(this, response, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, response, null))); } // ----------------------------------------------------------------------- @@ -147,7 +147,7 @@ public void HttpServerStream_StreamStopped_NullInternalErrorSwallowsFault() { EventHandler handler = (_, _) => throw new InvalidOperationException("StreamStopped fault"); - Assert.DoesNotThrow(() => handler.Raise(this, "stream-id-1", null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, "stream-id-1", null))); } // ----------------------------------------------------------------------- @@ -199,7 +199,7 @@ public void HttpServerStream_HeartbeatReceived_NullInternalErrorSwallowsFault() var args = new MTConnectHttpStreamArgs("stream-id-2", System.IO.Stream.Null, 42.5); EventHandler handler = (_, _) => throw new InvalidOperationException("HeartbeatReceived fault"); - Assert.DoesNotThrow(() => handler.Raise(this, args, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, args, null))); } // ----------------------------------------------------------------------- @@ -212,7 +212,7 @@ public void HttpServerStream_NullGenericHandler_DoesNotThrow() { EventHandler? handler = null; - Assert.DoesNotThrow(() => handler.Raise(this, "x", null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, "x", null))); } } } diff --git a/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj b/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj index 35a9f7f82..1c5a3e524 100644 --- a/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj +++ b/tests/MTConnect.NET-JSON-Tests/MTConnect.NET-JSON-Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj b/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj index e47b7842c..720d8d58d 100644 --- a/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj +++ b/tests/MTConnect.NET-JSON-cppagent-Tests/MTConnect.NET-JSON-cppagent-Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonConditionsArrayShapeTests.cs b/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonConditionsArrayShapeTests.cs index f62e62c36..ec7f90505 100644 --- a/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonConditionsArrayShapeTests.cs +++ b/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonConditionsArrayShapeTests.cs @@ -3,6 +3,7 @@ using MTConnect.Streams.Json; using NUnit.Framework; +using System; using System.Collections.Generic; using System.Text.Json; @@ -280,8 +281,8 @@ public void Null_WriteAndRead_RoundTripsToNull() [Test] public void Read_InvalidRootToken_ThrowsJsonException() { - var ex = Assert.Throws(() => - JsonSerializer.Deserialize("123", Options())); + var ex = Assert.Throws((Action)(() => + JsonSerializer.Deserialize("123", Options()))); Assert.That(ex, Is.Not.Null); Assert.That(ex!.Message, Does.Contain("Unexpected token")); } @@ -313,8 +314,8 @@ public void Read_ArrayShape_UnknownLevel_ThrowsJsonException() { const string json = "[{\"Bogus\":{\"dataItemId\":\"x1\"}}]"; - var ex = Assert.Throws(() => - JsonSerializer.Deserialize(json, Options())); + var ex = Assert.Throws((Action)(() => + JsonSerializer.Deserialize(json, Options()))); Assert.That(ex, Is.Not.Null); Assert.That(ex!.Message, Does.Contain("Unknown Condition level")); } @@ -325,8 +326,8 @@ public void Read_ArrayShape_NonObjectElement_ThrowsJsonException() { const string json = "[42]"; - var ex = Assert.Throws(() => - JsonSerializer.Deserialize(json, Options())); + var ex = Assert.Throws((Action)(() => + JsonSerializer.Deserialize(json, Options()))); Assert.That(ex, Is.Not.Null); Assert.That(ex!.Message, Does.Contain("expected object wrapper")); } @@ -337,8 +338,8 @@ public void Read_ArrayShape_WrapperWithoutPropertyName_ThrowsJsonException() { const string json = "[{}]"; - var ex = Assert.Throws(() => - JsonSerializer.Deserialize(json, Options())); + var ex = Assert.Throws((Action)(() => + JsonSerializer.Deserialize(json, Options()))); Assert.That(ex, Is.Not.Null); Assert.That(ex!.Message, Does.Contain("Expected property name")); } @@ -349,8 +350,8 @@ public void Read_ArrayShape_WrapperWithMultipleProperties_ThrowsJsonException() { const string json = "[{\"Fault\":{\"dataItemId\":\"f1\"},\"Warning\":{\"dataItemId\":\"w1\"}}]"; - var ex = Assert.Throws(() => - JsonSerializer.Deserialize(json, Options())); + var ex = Assert.Throws((Action)(() => + JsonSerializer.Deserialize(json, Options()))); Assert.That(ex, Is.Not.Null); Assert.That(ex!.Message, Does.Contain("end of JsonConditions wrapper")); } @@ -361,8 +362,8 @@ public void Read_ArrayShape_NullEntry_ThrowsJsonException() { const string json = "[{\"Normal\":null}]"; - var ex = Assert.Throws(() => - JsonSerializer.Deserialize(json, Options())); + var ex = Assert.Throws((Action)(() => + JsonSerializer.Deserialize(json, Options()))); Assert.That(ex, Is.Not.Null); Assert.That(ex!.Message, Does.Contain("Null Condition entry")); } @@ -373,8 +374,8 @@ public void Read_ObjectShape_UnknownLevel_ThrowsJsonException() { const string json = "{\"Bogus\":[{\"dataItemId\":\"x1\"}]}"; - var ex = Assert.Throws(() => - JsonSerializer.Deserialize(json, Options())); + var ex = Assert.Throws((Action)(() => + JsonSerializer.Deserialize(json, Options()))); Assert.That(ex, Is.Not.Null); Assert.That(ex!.Message, Does.Contain("Unknown Condition level")); } diff --git a/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueConverterEdgeCaseTests.cs b/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueConverterEdgeCaseTests.cs index cb16d108d..bee9e81af 100644 --- a/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueConverterEdgeCaseTests.cs +++ b/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueConverterEdgeCaseTests.cs @@ -1,6 +1,7 @@ // Copyright (c) 2026 TrakHound Inc., All Rights Reserved. // TrakHound Inc. licenses this file to you under the MIT license. +using System; using System.Text.Json; using MTConnect.NET_JSON_cppagent.Streams; using MTConnect.Streams.Json; @@ -139,7 +140,7 @@ public void Read_throws_for_unsupported_token(string payload) options.Converters.Add(converter); Assert.That( - () => JsonSerializer.Deserialize(payload, options), + (Action)(() => JsonSerializer.Deserialize(payload, options)), Throws.InstanceOf(), $"Unsupported token payload '{payload}' must surface as a " + "JsonException so feed corruption is visible to callers."); diff --git a/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueToObservationTests.cs b/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueToObservationTests.cs index 1729fa1da..8652262ec 100644 --- a/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueToObservationTests.cs +++ b/tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonSampleValueToObservationTests.cs @@ -5,6 +5,7 @@ using MTConnect.Observations; using MTConnect.Streams.Json; using NUnit.Framework; +using System; namespace MTConnect.NET_JSON_cppagent_Tests.Streams { @@ -35,7 +36,7 @@ public void ToObservation_with_null_reset_triggered_does_not_store_value() ISampleValueObservation? observation = null; Assert.That( - () => observation = sample.ToObservation("Temperature"), + (Action)(() => observation = sample.ToObservation("Temperature")), Throws.Nothing, "ToObservation must null-guard ResetTriggered/Statistic " + "rather than calling ConvertEnum on a null surface."); diff --git a/tests/MTConnect.NET-SHDR-Tests/MTConnect.NET-SHDR-Tests.csproj b/tests/MTConnect.NET-SHDR-Tests/MTConnect.NET-SHDR-Tests.csproj index 05c68a35e..a9dbfa642 100644 --- a/tests/MTConnect.NET-SHDR-Tests/MTConnect.NET-SHDR-Tests.csproj +++ b/tests/MTConnect.NET-SHDR-Tests/MTConnect.NET-SHDR-Tests.csproj @@ -8,7 +8,7 @@ - + all diff --git a/tests/MTConnect.NET-SHDR-Tests/ShdrMulticastIsolationTests.cs b/tests/MTConnect.NET-SHDR-Tests/ShdrMulticastIsolationTests.cs index 5e898affb..199dc2fc5 100644 --- a/tests/MTConnect.NET-SHDR-Tests/ShdrMulticastIsolationTests.cs +++ b/tests/MTConnect.NET-SHDR-Tests/ShdrMulticastIsolationTests.cs @@ -50,7 +50,7 @@ public void Shdr_Generic_EventHandlerOfString_NullInternalErrorSwallowsFault() { EventHandler handler = (_, _) => throw new InvalidOperationException("shdr-fault"); - Assert.DoesNotThrow(() => handler.Raise(this, "x", null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, "x", null))); } /// Pins the behavior expressed by the test name: multiple string-payload subscribers all fire when no subscriber throws, covering the happy path for AgentConnected and related events. @@ -98,7 +98,7 @@ public void Shdr_Generic_EventHandlerOfAdapterEventArgsString_NullInternalErrorS var payload = new AdapterEventArgs("c1", "data"); EventHandler> handler = (_, _) => throw new InvalidOperationException("fault"); - Assert.DoesNotThrow(() => handler.Raise(this, payload, null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, payload, null))); } // ----------------------------------------------------------------------- @@ -156,7 +156,7 @@ public void Shdr_NullGenericHandler_DoesNotThrow() { EventHandler handler = null; - Assert.DoesNotThrow(() => handler.Raise(this, "x", null)); + Assert.DoesNotThrow((Action)(() => handler.Raise(this, "x", null))); } } } diff --git a/tests/MTConnect.NET-XML-Tests/MTConnect.NET-XML-Tests.csproj b/tests/MTConnect.NET-XML-Tests/MTConnect.NET-XML-Tests.csproj index 2e1af056a..646f8f6b1 100644 --- a/tests/MTConnect.NET-XML-Tests/MTConnect.NET-XML-Tests.csproj +++ b/tests/MTConnect.NET-XML-Tests/MTConnect.NET-XML-Tests.csproj @@ -9,7 +9,7 @@ - + all diff --git a/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs b/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs index 032f3aa26..2ebccfa35 100644 --- a/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs +++ b/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs @@ -7,6 +7,7 @@ using MTConnect.Observations; using MTConnect.Streams.Xml; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace MTConnect.Tests.XML { @@ -35,10 +36,10 @@ public void TwoConditionsShouldBeParsed() using var xmlStream = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(text))); var doc = XmlStreamsResponseDocument.ReadXml(xmlStream); - Assert.AreEqual(1, doc.Streams.Count()); + ClassicAssert.AreEqual(1, doc.Streams.Count()); var stream = doc.Streams.Single(); var conditions = stream.Conditions.ToArray(); - Assert.AreEqual(2, conditions.Length); + ClassicAssert.AreEqual(2, conditions.Length); var cond1 = new ConditionObservation() { From 7f896003082439d35a30427761227e76022219c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Boly=C3=B3s?= Date: Wed, 19 Aug 2026 23:06:30 +0200 Subject: [PATCH 3/4] chore(tests): replace ClassicAssert.AreEqual with Assert.That form Ultrareview cycle 1 MEDIUM fix. Four independent agents (code-review F-CR-001, improvement F-IMP-002, simplification F-SIMP-001/F-SIMP-002) converged on the same recommendation: the three ClassicAssert.AreEqual sites left in the two files can move to the constraint-based Assert.That(actual, Is.EqualTo(expected)) idiom that the rest of the NUnit 4 upgrade already uses, which drops the only NUnit.Framework.Legacy imports the previous commit introduced and keeps a single assertion vocabulary across the test corpus. The prior commit chose ClassicAssert.AreEqual to sidestep NUnit 4s Assert.AreEqual extension-method shim (which requires C# 14). That sidestep is unnecessary: Assert.That has been NUnit s recommended constraint form since 3.x and has no C# 14 dependency, so it lands without any Legacy indirection. Behavior parity for value-type equality (string, int) is identical between ClassicAssert.AreEqual and Assert.That(x, Is.EqualTo(y)) at these sites; verified via focused test runs (both filters green). Sites changed: * tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs (1 site, drop using NUnit.Framework.Legacy) * tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs (2 sites, drop using NUnit.Framework.Legacy) Full-solution build: 0 warnings, 0 errors. --- .../Agents/AgentUuidDeterministicDefaultTests.cs | 3 +-- .../XmlStreamsResponseDocumentTests.cs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs b/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs index 714ddcc68..7c7c1416b 100644 --- a/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Agents/AgentUuidDeterministicDefaultTests.cs @@ -6,7 +6,6 @@ using MTConnect.Agents; using MTConnect.Configurations; using NUnit.Framework; -using NUnit.Framework.Legacy; namespace MTConnect.Tests.Common.Agents { @@ -124,7 +123,7 @@ private static string SimulateFreshBoot(string agentName, int port = 0) public void DeriveFromSeed_matches_python_uuid_v5_NAMESPACE_DNS_example_com_vector() { var derived = DeterministicAgentUuid.DeriveFromSeed("example.com"); - ClassicAssert.AreEqual("cfbff0d1-9375-5685-968c-48ce8b15ae17", derived, + Assert.That(derived, Is.EqualTo("cfbff0d1-9375-5685-968c-48ce8b15ae17"), "DeriveFromSeed must reproduce the canonical UUID v5(NAMESPACE_DNS, 'example.com') vector."); } diff --git a/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs b/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs index 2ebccfa35..496488d4f 100644 --- a/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs +++ b/tests/MTConnect.NET-XML-Tests/XmlStreamsResponseDocumentTests.cs @@ -7,7 +7,6 @@ using MTConnect.Observations; using MTConnect.Streams.Xml; using NUnit.Framework; -using NUnit.Framework.Legacy; namespace MTConnect.Tests.XML { @@ -36,10 +35,10 @@ public void TwoConditionsShouldBeParsed() using var xmlStream = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(text))); var doc = XmlStreamsResponseDocument.ReadXml(xmlStream); - ClassicAssert.AreEqual(1, doc.Streams.Count()); + Assert.That(doc.Streams.Count(), Is.EqualTo(1)); var stream = doc.Streams.Single(); var conditions = stream.Conditions.ToArray(); - ClassicAssert.AreEqual(2, conditions.Length); + Assert.That(conditions.Length, Is.EqualTo(2)); var cond1 = new ConditionObservation() { From 4d0975e6c7f748a7ab1c2737cb4b2b5537ec1908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Boly=C3=B3s?= Date: Fri, 21 Aug 2026 18:28:40 +0200 Subject: [PATCH 4/4] test(http): cast Assert.That async lambdas to (Func) for NUnit 4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NUnit 4 removed the AsyncTestDelegate overload for Assert.That in favour of Func — see 'Use Func instead of AsyncTestDelegate' obsoletion in nunit.framework.dll 4.6.1. CA2022ShortReadEdgeCaseTests.cs (arrived on master via merged #219) has two Assert.That(async () => ..., Throws.*) sites that trigger CS0121 overload ambiguity once NUnit 4 is active. Wrapping the async lambdas with (Func) disambiguates unambiguously. This closes the last of the 9-file Bug A cast-fix pass surfaced on the prior integration/up-to-pr-249 build (158 errors, 112 CS0121). The other 6 branches carry (Action) casts on sync sites in their own tests. --- .../Http/CA2022ShortReadEdgeCaseTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/MTConnect.NET-Common-Tests/Http/CA2022ShortReadEdgeCaseTests.cs b/tests/MTConnect.NET-Common-Tests/Http/CA2022ShortReadEdgeCaseTests.cs index 0d1926553..e77ba3e5b 100644 --- a/tests/MTConnect.NET-Common-Tests/Http/CA2022ShortReadEdgeCaseTests.cs +++ b/tests/MTConnect.NET-Common-Tests/Http/CA2022ShortReadEdgeCaseTests.cs @@ -122,7 +122,7 @@ public void ReadRequestBytes_pre_cancelled_token_throws_immediately() cts.Cancel(); Assert.That( - async () => await Invoke(scripted, cts.Token), + (Func)(async () => await Invoke(scripted, cts.Token)), Throws.InstanceOf(), "A pre-cancelled token must surface as OperationCanceledException. " + "Pre-fix, the accumulator ignored the token (signature took only Stream) " @@ -146,7 +146,7 @@ public void ReadRequestBytes_cancelled_mid_drip_throws_within_next_read() using var cts = new CancellationTokenSource(); Assert.That( - async () => + (Func)(async () => { var invocation = Invoke(slow, cts.Token); // Give the reader time to start awaiting the first drip, @@ -154,7 +154,7 @@ public void ReadRequestBytes_cancelled_mid_drip_throws_within_next_read() // Task.Delay(cancellationToken) throws immediately. cts.CancelAfter(TimeSpan.FromMilliseconds(50)); await invocation.WaitAsync(TimeSpan.FromMilliseconds(200)); - }, + }), Throws.InstanceOf(), "A token cancelled mid-drip must surface as OperationCanceledException within " + "the next ReadAsync cycle. Pre-fix, the accumulator ignored the token and "