From ac24123dde95f09cf6d3405cec96ca751fe5b146 Mon Sep 17 00:00:00 2001 From: romanett Date: Tue, 20 Oct 2026 05:15:12 +0200 Subject: [PATCH] Await NUnit 5 Assert.ThrowsAsync/CatchAsync in the #4759 tests; fixes the master build (#4852) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit master has failed to build since #4840 (NUnit 5) and #4759 (batch lifecycle and continuation tests) both landed: - #4759 calls `Assert.ThrowsAsync`/`Assert.CatchAsync` without `await`, which was the blocking NUnit 4 form. - Under NUnit 5 those methods return a `Task`. This PR adds the missing `await`, the same form as the rest of the migrated tests: - `NodeManagerLifecycleTests.Batch.cs`: six calls (`CS4014`, `NUnit2059`). - `ProductionDatasetClientTests.cs`: one call (`CS4014`). - `HistoryReadContinuationDispatchTests.FaultedRequestKeepsAssignedClientSuppliedContinuationPoint`: this test is synchronous, so it compiled. It discarded the returned `Task`, which means the assertion was never checked. It is now `async Task ...Async` and awaits it. No assertion changes. Tests (net10.0): - `UA.slnx` builds. - `NodeManagerLifecycleTests`: 317/317. - `ProductionDatasetClientTests`: 5/5. - `HistoryReadContinuationDispatchTests`: 6/6. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- .../ProductionDatasetClientTests.cs | 2 +- .../HistoryReadContinuationDispatchTests.cs | 4 ++-- .../NodeManager/NodeManagerLifecycleTests.Batch.cs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Opc.Ua.PlasticsRubber.Datasets.Tests/ProductionDatasetClientTests.cs b/tests/Opc.Ua.PlasticsRubber.Datasets.Tests/ProductionDatasetClientTests.cs index a6db23e18c..ebbbbb8d07 100644 --- a/tests/Opc.Ua.PlasticsRubber.Datasets.Tests/ProductionDatasetClientTests.cs +++ b/tests/Opc.Ua.PlasticsRubber.Datasets.Tests/ProductionDatasetClientTests.cs @@ -102,7 +102,7 @@ namespace Opc.Ua.PlasticsRubber.Datasets.Tests using var source = new MemoryStream([1]); Task upload = client.UploadAsync(Options(), source).AsTask(); await peer.CommitStarted.Task.WaitAsync(TimeSpan.FromSeconds(10)).ConfigureAwait(false); - Assert.CatchAsync(async () => await upload.ConfigureAwait(false)); + await Assert.CatchAsync(async () => await upload.ConfigureAwait(false)); Assert.That(peer.CommitCalls, Is.EqualTo(1)); } diff --git a/tests/Opc.Ua.Server.Tests/NodeManager/HistoryReadContinuationDispatchTests.cs b/tests/Opc.Ua.Server.Tests/NodeManager/HistoryReadContinuationDispatchTests.cs index a74ef75c53..766581e70b 100644 --- a/tests/Opc.Ua.Server.Tests/NodeManager/HistoryReadContinuationDispatchTests.cs +++ b/tests/Opc.Ua.Server.Tests/NodeManager/HistoryReadContinuationDispatchTests.cs @@ -154,14 +154,14 @@ namespace Opc.Ua.Server.Tests.NodeManager /// node manager restored, saved again and assigned to a result before it failed. /// [Test] - public void FaultedRequestKeepsAssignedClientSuppliedContinuationPoint() + public async Task FaultedRequestKeepsAssignedClientSuppliedContinuationPointAsync() { using var harness = new HistoryHarness(maxHistory: 10); var continued = new TrackingPoint(); harness.Points.SaveHistory(continued); harness.RestoreSaveAssignThenThrow(); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await harness.ReadAsync(1, ToByteString(continued.Id)).ConfigureAwait(false)); Assert.That(continued.Disposed, Is.False); diff --git a/tests/Opc.Ua.Server.Tests/NodeManager/NodeManagerLifecycleTests.Batch.cs b/tests/Opc.Ua.Server.Tests/NodeManager/NodeManagerLifecycleTests.Batch.cs index c0b29dae7b..5c3be148f7 100644 --- a/tests/Opc.Ua.Server.Tests/NodeManager/NodeManagerLifecycleTests.Batch.cs +++ b/tests/Opc.Ua.Server.Tests/NodeManager/NodeManagerLifecycleTests.Batch.cs @@ -216,7 +216,7 @@ namespace Opc.Ua.Server.Tests.NodeManager m_server.CurrentInstance.NamespaceUris.GetIndexOrAppend(kModelNamespaceUri)); m_server.CurrentInstance.TypeTree.AddSubtype(unrelated, Ua.ObjectTypeIds.BaseObjectType); int decisions = 0; - Assert.ThrowsAsync(async () => + await Assert.ThrowsAsync(async () => await prepared.CommitAsync(_ => { decisions++; @@ -693,7 +693,7 @@ namespace Opc.Ua.Server.Tests.NodeManager CreateOptions(kSecondModelNamespaceUri, kSecondRegistrationValue), null); int decisions = 0; - Assert.ThrowsAsync(async () => + await Assert.ThrowsAsync(async () => { await prepared.CommitAsync(_ => { @@ -748,7 +748,7 @@ namespace Opc.Ua.Server.Tests.NodeManager CreateOptions(kSecondModelNamespaceUri, kSecondRegistrationValue), null); int decisions = 0; - Assert.ThrowsAsync(async () => + await Assert.ThrowsAsync(async () => { await prepared.CommitAsync(_ => { @@ -787,7 +787,7 @@ namespace Opc.Ua.Server.Tests.NodeManager CreateOptions(kSecondModelNamespaceUri, 404))) ], null); - Assert.ThrowsAsync(async () => + await Assert.ThrowsAsync(async () => { await prepared.CommitAsync(_ => throw new IOException("Confirmed decision noncommit.")); }); @@ -822,7 +822,7 @@ namespace Opc.Ua.Server.Tests.NodeManager first, CreateOptions(kModelNamespaceUri, 505)); int decisions = 0; - Assert.ThrowsAsync(async () => + await Assert.ThrowsAsync(async () => { await prepared.CommitAsync(_ => { @@ -854,7 +854,7 @@ namespace Opc.Ua.Server.Tests.NodeManager cancellation.Cancel(); int decisions = 0; - Assert.CatchAsync(async () => + await Assert.CatchAsync(async () => { await prepared.CommitAsync(_ => {