diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b881875..334bae2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,7 +1,7 @@ Release notes ============== -### 1.3.10 (2024-05-13) +### 1.3.11 (2024-05-13) * Added `string` assertion `BeJsonEquivalentTo` * Added `HttpResponseMessage` assertion `HaveStringContentSatisfying`. Note that this is async and therefore not diff --git a/src/Faqt.Tests/TestUtils.fs b/src/Faqt.Tests/TestUtils.fs index 7b40fc7..8dbfda3 100644 --- a/src/Faqt.Tests/TestUtils.fs +++ b/src/Faqt.Tests/TestUtils.fs @@ -4,7 +4,6 @@ module TestUtils open System open System.Globalization open System.Runtime.CompilerServices -open System.Threading.Tasks open Faqt open Faqt.AssertionHelpers open Xunit @@ -23,9 +22,9 @@ let assertExnMsg (msg: string) (f: unit -> 'a) = ) -let assertExnMsgAsync (msg: string) (f: unit -> Task) = +let assertExnMsgAsync (msg: string) (f: unit -> Async) = task { - let! ex = Assert.ThrowsAsync(f) + let! ex = Assert.ThrowsAsync(f >> Async.StartImmediateAsTask >> (fun t -> upcast t)) Assert.Equal( ("\n\n" + msg.ReplaceLineEndings("\n").Trim() + "\n") :> obj, // Cast to obj to force full output diff --git a/src/Faqt/Faqt.fsproj b/src/Faqt/Faqt.fsproj index fe64348..0bebf80 100644 --- a/src/Faqt/Faqt.fsproj +++ b/src/Faqt/Faqt.fsproj @@ -2,7 +2,7 @@ net5.0;net7.0;net8.0 - 1.3.10 + 1.3.11 Christer van der Meeren A fluent assertion library for F#. MIT diff --git a/src/Faqt/HttpResponseMessageAssertions.fs b/src/Faqt/HttpResponseMessageAssertions.fs index 9cc6197..225a0c1 100644 --- a/src/Faqt/HttpResponseMessageAssertions.fs +++ b/src/Faqt/HttpResponseMessageAssertions.fs @@ -3,7 +3,6 @@ open System.Net open System.Net.Http open System.Runtime.CompilerServices -open System.Threading.Tasks open Faqt.AssertionHelpers @@ -576,8 +575,8 @@ type HttpResponseMessageAssertions = t: Testable, assertion: string -> 'ignored, ?because - ) : Task = - task { + ) : Async = + async { use _ = t.Assert(true) match t.Subject.Content with @@ -587,7 +586,8 @@ type HttpResponseMessageAssertions = .With("Request", t.Subject.RequestMessage) .Fail(because) | content -> - let! str = content.ReadAsStringAsync() + let! ct = Async.CancellationToken + let! str = content.ReadAsStringAsync(ct) |> Async.AwaitTask try assertion str |> ignore