From 72073533df862bcccbe294d8d9b105e5e56faed5 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 19 Oct 2026 21:00:20 +0200 Subject: [PATCH] Fix native QUIC NUnit 5 diagnostics --- .../NativeQuicBackendTests.cs | 30 ++++++++++--------- .../NativeQuicCancellationTests.cs | 10 +++---- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicBackendTests.cs b/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicBackendTests.cs index 4451e4bddf..95b66b0adc 100644 --- a/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicBackendTests.cs +++ b/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicBackendTests.cs @@ -36,12 +36,12 @@ namespace Opc.Ua.Native.QuicGo.Tests /// Refuses a wrong image digest before loading any Go runtime. /// [Test] - [Order(0)] - public void WrongAssetHashRefusedBeforeLoading() + public async Task WrongAssetHashRefusedBeforeLoadingAsync() { var backend = new NativeQuicBackend(new NativeQuicLibrary( m_library.AbsolutePath, new ByteString(new byte[32]))); - Assert.ThrowsAsync(async () => await backend.GetCountsAsync().ConfigureAwait(false)); + await Assert.ThrowsAsync( + async () => await backend.GetCountsAsync().ConfigureAwait(false)).ConfigureAwait(false); } /// @@ -51,7 +51,7 @@ namespace Opc.Ua.Native.QuicGo.Tests [TestCase(true, false, 91UL)] [TestCase(false, true, 91UL)] [TestCase(false, false, 0x52e4a40fa8dbUL)] - [Order(1)] + [DependsOnTest(nameof(WrongAssetHashRefusedBeforeLoadingAsync))] public async Task GenericNativeScenarioUsesRealSocketsAsync( bool passControlToken, bool cancelLifetimeFirst, ulong lateErrorCode) { @@ -67,7 +67,7 @@ namespace Opc.Ua.Native.QuicGo.Tests /// DI resolves the same injectable singleton and never changes the selected native image. /// [Test] - [Order(2)] + [DependsOnTest(nameof(GenericNativeScenarioUsesRealSocketsAsync), AllowFailure = true)] public async Task OptionalDependencyInjectionAndSingleImageLifetimeAsync() { var services = new ServiceCollection(); @@ -80,15 +80,15 @@ namespace Opc.Ua.Native.QuicGo.Tests Assert.That(await first.GetCountsAsync().ConfigureAwait(false), Is.Default); var other = new NativeQuicBackend(new NativeQuicLibrary( m_library.AbsolutePath + ".another", m_library.Sha256)); - Assert.ThrowsAsync(async () => - await other.GetCountsAsync().ConfigureAwait(false)); + await Assert.ThrowsAsync( + async () => await other.GetCountsAsync().ConfigureAwait(false)).ConfigureAwait(false); } /// /// Resolves the packaged RID filename and verifies the emitted hash sidecar without PATH probing. /// [Test] - [Order(3)] + [DependsOnTest(nameof(OptionalDependencyInjectionAndSingleImageLifetimeAsync), AllowFailure = true)] public async Task PackagedAssetSidecarSelectsTheReviewedImageAsync() { NativeQuicLibrary selected = await NativeQuicLibrary.FromDirectoryAsync( @@ -108,8 +108,8 @@ namespace Opc.Ua.Native.QuicGo.Tests var backend = new NativeQuicBackend(m_library); using var source = new CancellationTokenSource(); await source.CancelAsync().ConfigureAwait(false); - Assert.CatchAsync(async () => - await backend.GetCountsAsync(source.Token).ConfigureAwait(false)); + await Assert.CatchAsync(async () => + await backend.GetCountsAsync(source.Token).ConfigureAwait(false)).ConfigureAwait(false); Assert.That(await backend.GetCountsAsync().ConfigureAwait(false), Is.Default); } @@ -126,11 +126,13 @@ namespace Opc.Ua.Native.QuicGo.Tests Cancellation = control }; await control.CancelAsync(51).ConfigureAwait(false); - Assert.CatchAsync(async () => - await backend.StreamAsync(default, NativeQuicStreamOperation.Read, request).ConfigureAwait(false)); + await Assert.CatchAsync(async () => + await backend.StreamAsync(default, NativeQuicStreamOperation.Read, request).ConfigureAwait(false)) + .ConfigureAwait(false); control.Dispose(); - Assert.ThrowsAsync(async () => - await backend.StreamAsync(default, NativeQuicStreamOperation.Read, request).ConfigureAwait(false)); + await Assert.ThrowsAsync(async () => + await backend.StreamAsync(default, NativeQuicStreamOperation.Read, request).ConfigureAwait(false)) + .ConfigureAwait(false); Assert.That(await backend.GetCountsAsync().ConfigureAwait(false), Is.Default); } diff --git a/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicCancellationTests.cs b/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicCancellationTests.cs index 4a478c756b..c0b647eda0 100644 --- a/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicCancellationTests.cs +++ b/tests/Opc.Ua.Native.QuicGo.Tests/NativeQuicCancellationTests.cs @@ -64,8 +64,8 @@ namespace Opc.Ua.Native.QuicGo.Tests public async Task InvalidCodeDoesNotPublishCancellationAsync(ulong errorCode) { using var cancellation = new NativeQuicCancellation(); - Assert.ThrowsAsync(async () => - await cancellation.CancelAsync(errorCode).ConfigureAwait(false)); + await Assert.ThrowsAsync(async () => + await cancellation.CancelAsync(errorCode).ConfigureAwait(false)).ConfigureAwait(false); Assert.That(cancellation.IsCancellationRequested, Is.False); Assert.That(cancellation.Token.IsCancellationRequested, Is.False); Assert.That(cancellation.ErrorCode, Is.Zero); @@ -77,7 +77,7 @@ namespace Opc.Ua.Native.QuicGo.Tests /// Disposal releases resources without an implicit cancellation or a replacement error. /// [Test] - public void DisposalDoesNotCancelOrPermitAnotherRequest() + public async Task DisposalDoesNotCancelOrPermitAnotherRequest() { var cancellation = new NativeQuicCancellation(); CancellationToken token = cancellation.Token; @@ -85,8 +85,8 @@ namespace Opc.Ua.Native.QuicGo.Tests cancellation.Dispose(); Assert.That(token.IsCancellationRequested, Is.False); Assert.That(cancellation.IsCancellationRequested, Is.False); - Assert.ThrowsAsync(async () => - await cancellation.CancelAsync(7).ConfigureAwait(false)); + await Assert.ThrowsAsync(async () => + await cancellation.CancelAsync(7).ConfigureAwait(false)).ConfigureAwait(false); } } }