From d05ac52829256833c75d7353b753b405fcab0ed2 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 22 Aug 2026 03:46:06 +0100 Subject: [PATCH] tests(org): forward CancellationToken to ReceiveEstimateSignatureAsync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xUnit1051 in two cases that call EstimateSignatureFileHelper.ReceiveEstimateSignatureAsync through Assert.ThrowsAsync lambdas. The lambda body runs on a different stack frame, so capturing TestContext.Current.CancellationToken in a local variable before the lambda is required — otherwise xUnit1051 still flags the call (the implicit 'default' from the parameter default lives in the lambda's scope, not the test's). The 2 xUnit1013 warnings on BaseTestContext.GitClone remain — unrelated, about visibility vs [Fact] attribute on a helper method, structural cleanup for another commit. --- src/Yavsc.Org.Tests/EstimateSignatureFileHelperTests.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Yavsc.Org.Tests/EstimateSignatureFileHelperTests.cs b/src/Yavsc.Org.Tests/EstimateSignatureFileHelperTests.cs index d4e52cc4..69009432 100644 --- a/src/Yavsc.Org.Tests/EstimateSignatureFileHelperTests.cs +++ b/src/Yavsc.Org.Tests/EstimateSignatureFileHelperTests.cs @@ -91,9 +91,13 @@ public class EstimateSignatureFileHelperTests : IDisposable public async Task ReceiveEstimateSignatureAsync_rejects_null_payload() { var user = MakeUser("bob"); + // Capture TestContext.Current.CancellationToken outside the + // lambda so xUnit1051 sees a real CancellationToken argument + // (the lambda body runs on a different stack frame). + var ct = TestContext.Current.CancellationToken; await Assert.ThrowsAsync(() => EstimateSignatureFileHelper.ReceiveEstimateSignatureAsync( - user, 1L, SignatureType.Pro, payload: null!)); + user, 1L, SignatureType.Pro, payload: null!, token: ct)); } [Fact] @@ -101,9 +105,10 @@ public class EstimateSignatureFileHelperTests : IDisposable { var user = MakeUser("bob"); var payload = new SignaturePadPayload { Strokes = new[] { 1, 100, 100 } }; + var ct = TestContext.Current.CancellationToken; await Assert.ThrowsAsync(() => EstimateSignatureFileHelper.ReceiveEstimateSignatureAsync( - user, 0L, SignatureType.Pro, payload)); + user, 0L, SignatureType.Pro, payload, token: ct)); } // --- helpers ----------------------------------------------------