Await NUnit 5 Assert.ThrowsAsync/CatchAsync in the #4759 tests; fixes the master build (#4852)

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 <noreply@anthropic.com>
This commit is contained in:
romanett
2026-10-20 05:15:12 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 2997cb8a2c
commit ac24123dde
3 changed files with 9 additions and 9 deletions
@@ -102,7 +102,7 @@ namespace Opc.Ua.PlasticsRubber.Datasets.Tests
using var source = new MemoryStream([1]); using var source = new MemoryStream([1]);
Task upload = client.UploadAsync(Options(), source).AsTask(); Task upload = client.UploadAsync(Options(), source).AsTask();
await peer.CommitStarted.Task.WaitAsync(TimeSpan.FromSeconds(10)).ConfigureAwait(false); await peer.CommitStarted.Task.WaitAsync(TimeSpan.FromSeconds(10)).ConfigureAwait(false);
Assert.CatchAsync<OperationCanceledException>(async () => await upload.ConfigureAwait(false)); await Assert.CatchAsync<OperationCanceledException>(async () => await upload.ConfigureAwait(false));
Assert.That(peer.CommitCalls, Is.EqualTo(1)); Assert.That(peer.CommitCalls, Is.EqualTo(1));
} }
@@ -154,14 +154,14 @@ namespace Opc.Ua.Server.Tests.NodeManager
/// node manager restored, saved again and assigned to a result before it failed. /// node manager restored, saved again and assigned to a result before it failed.
/// </summary> /// </summary>
[Test] [Test]
public void FaultedRequestKeepsAssignedClientSuppliedContinuationPoint() public async Task FaultedRequestKeepsAssignedClientSuppliedContinuationPointAsync()
{ {
using var harness = new HistoryHarness(maxHistory: 10); using var harness = new HistoryHarness(maxHistory: 10);
var continued = new TrackingPoint(); var continued = new TrackingPoint();
harness.Points.SaveHistory(continued); harness.Points.SaveHistory(continued);
harness.RestoreSaveAssignThenThrow(); harness.RestoreSaveAssignThenThrow();
Assert.ThrowsAsync<OperationCanceledException>( await Assert.ThrowsAsync<OperationCanceledException>(
async () => await harness.ReadAsync(1, ToByteString(continued.Id)).ConfigureAwait(false)); async () => await harness.ReadAsync(1, ToByteString(continued.Id)).ConfigureAwait(false));
Assert.That(continued.Disposed, Is.False); Assert.That(continued.Disposed, Is.False);
@@ -216,7 +216,7 @@ namespace Opc.Ua.Server.Tests.NodeManager
m_server.CurrentInstance.NamespaceUris.GetIndexOrAppend(kModelNamespaceUri)); m_server.CurrentInstance.NamespaceUris.GetIndexOrAppend(kModelNamespaceUri));
m_server.CurrentInstance.TypeTree.AddSubtype(unrelated, Ua.ObjectTypeIds.BaseObjectType); m_server.CurrentInstance.TypeTree.AddSubtype(unrelated, Ua.ObjectTypeIds.BaseObjectType);
int decisions = 0; int decisions = 0;
Assert.ThrowsAsync<InvalidOperationException>(async () => await Assert.ThrowsAsync<InvalidOperationException>(async () =>
await prepared.CommitAsync(_ => await prepared.CommitAsync(_ =>
{ {
decisions++; decisions++;
@@ -693,7 +693,7 @@ namespace Opc.Ua.Server.Tests.NodeManager
CreateOptions(kSecondModelNamespaceUri, kSecondRegistrationValue), null); CreateOptions(kSecondModelNamespaceUri, kSecondRegistrationValue), null);
int decisions = 0; int decisions = 0;
Assert.ThrowsAsync<InvalidOperationException>(async () => await Assert.ThrowsAsync<InvalidOperationException>(async () =>
{ {
await prepared.CommitAsync(_ => await prepared.CommitAsync(_ =>
{ {
@@ -748,7 +748,7 @@ namespace Opc.Ua.Server.Tests.NodeManager
CreateOptions(kSecondModelNamespaceUri, kSecondRegistrationValue), null); CreateOptions(kSecondModelNamespaceUri, kSecondRegistrationValue), null);
int decisions = 0; int decisions = 0;
Assert.ThrowsAsync<InvalidOperationException>(async () => await Assert.ThrowsAsync<InvalidOperationException>(async () =>
{ {
await prepared.CommitAsync(_ => await prepared.CommitAsync(_ =>
{ {
@@ -787,7 +787,7 @@ namespace Opc.Ua.Server.Tests.NodeManager
CreateOptions(kSecondModelNamespaceUri, 404))) CreateOptions(kSecondModelNamespaceUri, 404)))
], null); ], null);
Assert.ThrowsAsync<IOException>(async () => await Assert.ThrowsAsync<IOException>(async () =>
{ {
await prepared.CommitAsync(_ => throw new IOException("Confirmed decision noncommit.")); await prepared.CommitAsync(_ => throw new IOException("Confirmed decision noncommit."));
}); });
@@ -822,7 +822,7 @@ namespace Opc.Ua.Server.Tests.NodeManager
first, CreateOptions(kModelNamespaceUri, 505)); first, CreateOptions(kModelNamespaceUri, 505));
int decisions = 0; int decisions = 0;
Assert.ThrowsAsync<InvalidOperationException>(async () => await Assert.ThrowsAsync<InvalidOperationException>(async () =>
{ {
await prepared.CommitAsync(_ => await prepared.CommitAsync(_ =>
{ {
@@ -854,7 +854,7 @@ namespace Opc.Ua.Server.Tests.NodeManager
cancellation.Cancel(); cancellation.Cancel();
int decisions = 0; int decisions = 0;
Assert.CatchAsync<OperationCanceledException>(async () => await Assert.CatchAsync<OperationCanceledException>(async () =>
{ {
await prepared.CommitAsync(_ => await prepared.CommitAsync(_ =>
{ {