Skip to content

Commit 6cef2b1

Browse files
committed
Merge PR TrakHound#239 (chore/nunit-4-upgrade) into integration/up-to-pr-239
Cascade rebuild after upstream/master advanced to 0ddc3c6 (PR TrakHound#220 merge). # Conflicts: # tests/MTConnect.NET-Common-Tests/V2_6_V2_7/V2_7DataItemTypeTests.cs # tests/MTConnect.NET-JSON-cppagent-Tests/Streams/JsonConditionsArrayShapeTests.cs
2 parents 1d8f6a8 + c68c0e9 commit 6cef2b1

32 files changed

Lines changed: 113 additions & 109 deletions

tests/Compliance/MTConnect-Compliance-Tests/MTConnect-Compliance-Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
1313
<PackageReference Include="MQTTnet" Version="4.3.7.1207" />
14-
<PackageReference Include="NUnit" Version="3.13.3" />
15-
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
14+
<PackageReference Include="NUnit" Version="4.6.1" />
15+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
1616
<PackageReference Include="Testcontainers" Version="3.10.0" />
1717
<PackageReference Include="coverlet.collector" Version="6.0.4" />
1818
</ItemGroup>

tests/MTConnect.NET-AgentModule-MqttRelay-Tests/LastSentSequencePersisterTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// TrakHound Inc. licenses this file to you under the MIT license.
33

44
using NUnit.Framework;
5+
using System;
56

67
namespace MTConnect.AgentModule.MqttRelay.Tests
78
{
@@ -90,7 +91,7 @@ public void TryFlush_keeps_dirty_when_writer_throws()
9091
persister.Update(123UL);
9192

9293
Assert.Throws<System.IO.IOException>(
93-
() => persister.TryFlush(_ => throw new System.IO.IOException("disk full")));
94+
(Action)(() => persister.TryFlush(_ => throw new System.IO.IOException("disk full"))));
9495

9596
Assert.That(persister.IsDirty, Is.True,
9697
"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()
135136
// A null writer means the caller has not wired persistence
136137
// (e.g. DurableRelay disabled at runtime); the persister
137138
// must not throw.
138-
Assert.DoesNotThrow(() => persister.TryFlush(null));
139+
Assert.DoesNotThrow((Action)(() => persister.TryFlush(null)));
139140
// Dirty bit unchanged because no write happened.
140141
Assert.That(persister.IsDirty, Is.True);
141142
}

tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MTConnect.NET-AgentModule-MqttRelay-Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
11-
<PackageReference Include="NUnit" Version="3.13.3" />
12-
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
11+
<PackageReference Include="NUnit" Version="4.6.1" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
1313
<PackageReference Include="coverlet.collector" Version="6.0.4">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleDisconnectTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ public void DisconnectWithTimeout_does_not_throw_when_disconnect_factory_throws_
8989
// and route the exception to the fault logger.
9090
string loggedFault = null;
9191

92-
Assert.DoesNotThrow(() => MqttRelayLifecycle.DisconnectWithTimeout(
92+
Assert.DoesNotThrow((Action)(() => MqttRelayLifecycle.DisconnectWithTimeout(
9393
disconnect: () => throw new InvalidOperationException("sync throw"),
9494
timeout: TimeSpan.FromSeconds(1),
95-
onFault: ex => loggedFault = ex.Message));
95+
onFault: ex => loggedFault = ex.Message)));
9696

9797
Assert.That(loggedFault, Is.EqualTo("sync throw"));
9898
}
@@ -104,10 +104,10 @@ public void DisconnectWithTimeout_no_ops_when_disconnect_factory_is_null()
104104
// The shutdown path must tolerate a null disconnect factory
105105
// (for example when _mqttClient is null because the worker
106106
// never ran).
107-
Assert.DoesNotThrow(() => MqttRelayLifecycle.DisconnectWithTimeout(
107+
Assert.DoesNotThrow((Action)(() => MqttRelayLifecycle.DisconnectWithTimeout(
108108
disconnect: null,
109109
timeout: TimeSpan.FromSeconds(1),
110-
onFault: _ => { }));
110+
onFault: _ => { })));
111111
}
112112
}
113113
}

tests/MTConnect.NET-AgentModule-MqttRelay-Tests/MqttRelayLifecycleStopTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// TrakHound Inc. licenses this file to you under the MIT license.
33

44
using NUnit.Framework;
5+
using System;
56

67
namespace MTConnect.AgentModule.MqttRelay.Tests
78
{
@@ -32,7 +33,7 @@ public void StopServers_does_not_throw_when_both_servers_null()
3233
// either server is the worst case; the helper must be a
3334
// total function over (null, null).
3435
Assert.DoesNotThrow(
35-
() => MqttRelayLifecycle.StopServers(documentStop: null, entityStop: null));
36+
(Action)(() => MqttRelayLifecycle.StopServers(documentStop: null, entityStop: null)));
3637
}
3738

3839
/// <summary>Pins the behaviour expressed by the test name: stop servers invokes document stop when provided.</summary>
@@ -85,9 +86,9 @@ public void StopServers_swallows_document_stop_exception_and_runs_entity_stop()
8586
// shutdown leaks live handlers.
8687
var entityStopped = false;
8788

88-
Assert.DoesNotThrow(() => MqttRelayLifecycle.StopServers(
89+
Assert.DoesNotThrow((Action)(() => MqttRelayLifecycle.StopServers(
8990
documentStop: () => throw new System.InvalidOperationException("doc"),
90-
entityStop: () => entityStopped = true));
91+
entityStop: () => entityStopped = true)));
9192

9293
Assert.That(entityStopped, Is.True);
9394
}

tests/MTConnect.NET-AgentModule-MqttRelay-Tests/WorkerLoopExceptionLoggerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public void Log_no_ops_when_callback_is_null()
9595
// Defensive: the helper must not throw when the logger is
9696
// not wired (would defeat the purpose of catching the
9797
// unexpected exception).
98-
Assert.DoesNotThrow(() => WorkerLoopExceptionLogger.Log(
98+
Assert.DoesNotThrow((Action)(() => WorkerLoopExceptionLogger.Log(
9999
exception: new InvalidOperationException("boom"),
100-
onLog: null));
100+
onLog: null)));
101101
}
102102

103103
/// <summary>Pins the behaviour expressed by the test name: log treats subclass of task canceled exception as cancellation.</summary>

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void Agent_DeviceAdded_NullInternalErrorSwallowsFault()
6565
var device = new Device { Name = "device-1", Uuid = "uuid-1" };
6666
EventHandler<IDevice> handler = (_, _) => throw new InvalidOperationException("DeviceAdded fault");
6767

68-
Assert.DoesNotThrow(() => handler.Raise(this, (IDevice)device, null));
68+
Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IDevice)device, null)));
6969
}
7070

7171
// -----------------------------------------------------------------------
@@ -96,7 +96,7 @@ public void Agent_ObservationReceived_NullInternalErrorSwallowsFault()
9696
var obs = new ObservationInput();
9797
EventHandler<IObservationInput> handler = (_, _) => throw new InvalidOperationException("ObservationReceived fault");
9898

99-
Assert.DoesNotThrow(() => handler.Raise(this, (IObservationInput)obs, null));
99+
Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IObservationInput)obs, null)));
100100
}
101101

102102
// -----------------------------------------------------------------------
@@ -127,7 +127,7 @@ public void Agent_ObservationAdded_NullInternalErrorSwallowsFault()
127127
var obs = new Observation();
128128
EventHandler<IObservation> handler = (_, _) => throw new InvalidOperationException("ObservationAdded fault");
129129

130-
Assert.DoesNotThrow(() => handler.Raise(this, (IObservation)obs, null));
130+
Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IObservation)obs, null)));
131131
}
132132

133133
// -----------------------------------------------------------------------
@@ -158,7 +158,7 @@ public void Agent_AssetAdded_NullInternalErrorSwallowsFault()
158158
var asset = new Asset { AssetId = "a1", Timestamp = DateTime.UtcNow };
159159
EventHandler<IAsset> handler = (_, _) => throw new InvalidOperationException("AssetAdded fault");
160160

161-
Assert.DoesNotThrow(() => handler.Raise(this, (IAsset)asset, null));
161+
Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IAsset)asset, null)));
162162
}
163163

164164
// -----------------------------------------------------------------------
@@ -187,7 +187,7 @@ public void AgentBroker_StreamsResponseSent_NullInternalErrorSwallowsFault()
187187
{
188188
EventHandler handler = (_, _) => throw new InvalidOperationException("StreamsResponseSent fault");
189189

190-
Assert.DoesNotThrow(() => handler.Raise(this, EventArgs.Empty, null));
190+
Assert.DoesNotThrow((Action)(() => handler.Raise(this, EventArgs.Empty, null)));
191191
}
192192

193193
// -----------------------------------------------------------------------
@@ -201,7 +201,7 @@ public void Agent_NullGenericHandler_DoesNotThrow()
201201
EventHandler<IDevice>? handler = null;
202202
var device = new Device { Name = "noop-device", Uuid = "noop-uuid" };
203203

204-
Assert.DoesNotThrow(() => handler.Raise(this, (IDevice)device, null));
204+
Assert.DoesNotThrow((Action)(() => handler.Raise(this, (IDevice)device, null)));
205205
}
206206

207207
/// <summary>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.</summary>
@@ -210,7 +210,7 @@ public void AgentBroker_NullNonGenericHandler_DoesNotThrow()
210210
{
211211
EventHandler? handler = null;
212212

213-
Assert.DoesNotThrow(() => handler.Raise(this, EventArgs.Empty, null));
213+
Assert.DoesNotThrow((Action)(() => handler.Raise(this, EventArgs.Empty, null)));
214214
}
215215

216216
// =======================================================================
@@ -246,7 +246,7 @@ public void Agent_InvalidDeviceAdded_NullInternalErrorSwallowsFault()
246246
var result = new ValidationResult(false, "bad device");
247247
MTConnectDeviceValidationHandler handler = (_, _) => throw new InvalidOperationException("InvalidDeviceAdded fault");
248248

249-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(device, result)));
249+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(device, result))));
250250
}
251251

252252
// -----------------------------------------------------------------------
@@ -278,7 +278,7 @@ public void Agent_InvalidComponentAdded_NullInternalErrorSwallowsFault()
278278
var result = new ValidationResult(false, "bad component");
279279
MTConnectComponentValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidComponentAdded fault");
280280

281-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", component, result)));
281+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", component, result))));
282282
}
283283

284284
// -----------------------------------------------------------------------
@@ -310,7 +310,7 @@ public void Agent_InvalidCompositionAdded_NullInternalErrorSwallowsFault()
310310
var result = new ValidationResult(false, "bad composition");
311311
MTConnectCompositionValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidCompositionAdded fault");
312312

313-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", composition, result)));
313+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", composition, result))));
314314
}
315315

316316
// -----------------------------------------------------------------------
@@ -342,7 +342,7 @@ public void Agent_InvalidDataItemAdded_NullInternalErrorSwallowsFault()
342342
var result = new ValidationResult(false, "bad data item");
343343
MTConnectDataItemValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidDataItemAdded fault");
344344

345-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", dataItem, result)));
345+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", dataItem, result))));
346346
}
347347

348348
// -----------------------------------------------------------------------
@@ -372,7 +372,7 @@ public void Agent_InvalidObservationAdded_NullInternalErrorSwallowsFault()
372372
var result = new ValidationResult(false, "bad observation");
373373
MTConnectObservationValidationHandler handler = (_, _, _) => throw new InvalidOperationException("InvalidObservationAdded fault");
374374

375-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1", "key-1", result)));
375+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1", "key-1", result))));
376376
}
377377

378378
// -----------------------------------------------------------------------
@@ -404,7 +404,7 @@ public void Agent_InvalidAssetAdded_NullInternalErrorSwallowsFault()
404404
var result = new ValidationResult(false, "bad asset");
405405
MTConnectAssetValidationHandler handler = (_, _) => throw new InvalidOperationException("InvalidAssetAdded fault");
406406

407-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(asset, result)));
407+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(asset, result))));
408408
}
409409

410410
// =======================================================================
@@ -435,7 +435,7 @@ public void AgentBroker_DevicesRequestReceived_NullInternalErrorSwallowsFault()
435435
{
436436
MTConnectDevicesRequestedHandler handler = _ => throw new InvalidOperationException("DevicesRequestReceived fault");
437437

438-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1")));
438+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1"))));
439439
}
440440

441441
// -----------------------------------------------------------------------
@@ -462,7 +462,7 @@ public void AgentBroker_DevicesResponseSent_NullInternalErrorSwallowsFault()
462462
{
463463
MTConnectDevicesHandler handler = _ => throw new InvalidOperationException("DevicesResponseSent fault");
464464

465-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(null!)));
465+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(null!))));
466466
}
467467

468468
// -----------------------------------------------------------------------
@@ -489,7 +489,7 @@ public void AgentBroker_StreamsRequestReceived_NullInternalErrorSwallowsFault()
489489
{
490490
MTConnectStreamsRequestedHandler handler = _ => throw new InvalidOperationException("StreamsRequestReceived fault");
491491

492-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1")));
492+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1"))));
493493
}
494494

495495
// -----------------------------------------------------------------------
@@ -518,7 +518,7 @@ public void AgentBroker_AssetsRequestReceived_NullInternalErrorSwallowsFault()
518518
var ids = new[] { "asset-1" };
519519
MTConnectAssetsRequestedHandler handler = _ => throw new InvalidOperationException("AssetsRequestReceived fault");
520520

521-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(ids)));
521+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(ids))));
522522
}
523523

524524
// -----------------------------------------------------------------------
@@ -545,7 +545,7 @@ public void AgentBroker_DeviceAssetsRequestReceived_NullInternalErrorSwallowsFau
545545
{
546546
MTConnectDeviceAssetsRequestedHandler handler = _ => throw new InvalidOperationException("DeviceAssetsRequestReceived fault");
547547

548-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h("uuid-1")));
548+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h("uuid-1"))));
549549
}
550550

551551
// -----------------------------------------------------------------------
@@ -572,7 +572,7 @@ public void AgentBroker_AssetsResponseSent_NullInternalErrorSwallowsFault()
572572
{
573573
MTConnectAssetsHandler handler = _ => throw new InvalidOperationException("AssetsResponseSent fault");
574574

575-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h(null!)));
575+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h(null!))));
576576
}
577577

578578
// -----------------------------------------------------------------------
@@ -599,7 +599,7 @@ public void AgentBroker_ErrorResponseSent_NullInternalErrorSwallowsFault()
599599
{
600600
MTConnectErrorHandler handler = _ => throw new InvalidOperationException("ErrorResponseSent fault");
601601

602-
Assert.DoesNotThrow(() => MulticastIsolation.Raise(handler, h => h((IErrorResponseDocument)null!)));
602+
Assert.DoesNotThrow((Action)(() => MulticastIsolation.Raise(handler, h => h((IErrorResponseDocument)null!))));
603603
}
604604
}
605605
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static string SimulateFreshBoot(string agentName, int port = 0)
123123
public void DeriveFromSeed_matches_python_uuid_v5_NAMESPACE_DNS_example_com_vector()
124124
{
125125
var derived = DeterministicAgentUuid.DeriveFromSeed("example.com");
126-
Assert.AreEqual("cfbff0d1-9375-5685-968c-48ce8b15ae17", derived,
126+
Assert.That(derived, Is.EqualTo("cfbff0d1-9375-5685-968c-48ce8b15ae17"),
127127
"DeriveFromSeed must reproduce the canonical UUID v5(NAMESPACE_DNS, 'example.com') vector.");
128128
}
129129

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)