From b9834dcec44157efda68d20805933973485e8224 Mon Sep 17 00:00:00 2001 From: Constantin Tews Date: Fri, 7 Jul 2023 21:00:32 +0200 Subject: [PATCH 1/7] Update dependencies. --- paket.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/paket.lock b/paket.lock index 18057e0a..edc8b9d4 100644 --- a/paket.lock +++ b/paket.lock @@ -2,17 +2,17 @@ RESTRICTION: || (== net6.0) (== netstandard2.0) NUGET remote: https://api.nuget.org/v3/index.json FSharp.Core (5.0.2) - Microsoft.CodeCoverage (17.6.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) - Microsoft.NET.Test.Sdk (17.6.2) - Microsoft.CodeCoverage (>= 17.6.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) - Microsoft.TestPlatform.TestHost (>= 17.6.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) - Microsoft.NETCore.Platforms (7.0.2) + Microsoft.CodeCoverage (17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.NET.Test.Sdk (17.6.3) + Microsoft.CodeCoverage (>= 17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.TestPlatform.TestHost (>= 17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.NETCore.Platforms (7.0.3) Microsoft.NETCore.Targets (5.0) - Microsoft.TestPlatform.ObjectModel (17.6.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.TestPlatform.ObjectModel (17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) NuGet.Frameworks (>= 6.5) System.Reflection.Metadata (>= 1.6) - Microsoft.TestPlatform.TestHost (17.6.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) - Microsoft.TestPlatform.ObjectModel (>= 17.6.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.TestPlatform.TestHost (17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.TestPlatform.ObjectModel (>= 17.6.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) Newtonsoft.Json (>= 13.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) MSTest.TestAdapter (2.1.2) NETStandard.Library (>= 1.6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp1.0)) @@ -21,8 +21,8 @@ NUGET NETStandard.Library (2.0.3) Microsoft.NETCore.Platforms (>= 1.1) Newtonsoft.Json (13.0.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) - NHamcrest (3.1) - NuGet.Frameworks (6.6) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + NHamcrest (3.2) + NuGet.Frameworks (6.6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) NUnit (3.13.3) NETStandard.Library (>= 2.0) NUnit3TestAdapter (4.5) @@ -86,7 +86,7 @@ NUGET System.IO (>= 4.3) System.Reflection.Primitives (>= 4.3) System.Runtime (>= 4.3) - System.Reflection.Metadata (7.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + System.Reflection.Metadata (7.0.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) System.Collections.Immutable (>= 7.0) System.Reflection.Primitives (4.3) Microsoft.NETCore.Platforms (>= 1.1) @@ -117,21 +117,21 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) System.Runtime (>= 4.3) - xunit (2.4.2) - xunit.analyzers (>= 1.0) - xunit.assert (>= 2.4.2) - xunit.core (2.4.2) + xunit (2.5) + xunit.analyzers (>= 1.2) + xunit.assert (>= 2.5) + xunit.core (2.5) xunit.abstractions (2.0.3) - xunit.analyzers (1.1) - xunit.assert (2.4.2) + xunit.analyzers (1.2) + xunit.assert (2.5) NETStandard.Library (>= 1.6.1) - xunit.core (2.4.2) - xunit.extensibility.core (2.4.2) - xunit.extensibility.execution (2.4.2) - xunit.extensibility.core (2.4.2) + xunit.core (2.5) + xunit.extensibility.core (2.5) + xunit.extensibility.execution (2.5) + xunit.extensibility.core (2.5) NETStandard.Library (>= 1.6.1) xunit.abstractions (>= 2.0.3) - xunit.extensibility.execution (2.4.2) + xunit.extensibility.execution (2.5) NETStandard.Library (>= 1.6.1) - xunit.extensibility.core (2.4.2) - xunit.runner.visualstudio (2.4.5) + xunit.extensibility.core (2.5) + xunit.runner.visualstudio (2.5) From 80429464993484f4f7aba3901440368e44516099 Mon Sep 17 00:00:00 2001 From: Constantin Tews Date: Fri, 7 Jul 2023 22:43:17 +0200 Subject: [PATCH 2/7] Remove MatchException to satisfy xunit 2.5.0. --- src/FsUnit.Xunit/FsUnit.fs | 7 ++----- tests/FsUnit.Xunit.Test/beGreaterThanTests.fs | 7 ------- tests/FsUnit.Xunit.Test/beSubsetOfTests.fs | 7 ------- tests/FsUnit.Xunit.Test/equalTests.fs | 7 ------- tests/FsUnit.Xunit.Test/haveLengthTests.fs | 7 ------- tests/FsUnit.Xunit.Test/shouldFailTests.fs | 5 +++-- tests/FsUnit.Xunit.Test/shouldStartWithTests.fs | 6 ------ .../FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs | 6 +++--- tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs | 9 +++++---- 9 files changed, 13 insertions(+), 48 deletions(-) diff --git a/src/FsUnit.Xunit/FsUnit.fs b/src/FsUnit.Xunit/FsUnit.fs index bbb22c24..65dd16f4 100644 --- a/src/FsUnit.Xunit/FsUnit.fs +++ b/src/FsUnit.Xunit/FsUnit.fs @@ -6,9 +6,6 @@ open Xunit.Sdk open NHamcrest open NHamcrest.Core -type MatchException(expected, actual, userMessage) = - inherit AssertActualExpectedException(expected, actual, userMessage) - type Xunit.Assert with static member That<'a>(actual, matcher: IMatcher<'a>) = @@ -17,7 +14,7 @@ type Xunit.Assert with matcher.DescribeTo(description) let raiseMatchException(value: string) = - raise(MatchException(description.ToString(), value, null)) + raise(EqualException.ForMismatchedValues(description.ToString(), value, null)) match box actual with | :? (unit -> unit) as actualfunc -> @@ -52,7 +49,7 @@ let inline shouldFail(f: unit -> unit) = true if not failed then - raise(MatchException("Method should fail", "No exception raised", null)) + raise(EqualException.ForMismatchedValues("Method should fail", "No exception raised", null)) let equalSeq expected = CustomMatchers.equalSeq (fun (e: seq<'a>) (a: seq<'a>) -> Assert.Equal>(e, a)) expected diff --git a/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs b/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs index 6187e1e9..c0dbad1c 100644 --- a/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs +++ b/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs @@ -23,10 +23,3 @@ type ``be greaterThan tests``() = [] member _.``9[dot]2 should not be greater than 9[dot]2``() = 9.2 |> should not' (be greaterThan 9.2) - - [] - member _.``10 should not be greater than 10 but messages should equal``() = - (fun () -> 10 |> should be (greaterThan 10)) - |> fun f -> Assert.Throws(f) - |> fun e -> (e.Expected, e.Actual) - |> should equal ("Greater than 10", "10") diff --git a/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs b/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs index 6b32916a..c40c5f4c 100644 --- a/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs +++ b/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs @@ -36,10 +36,3 @@ type ``be subsetOf tests``() = [] member _.``should fail on '1 to 11 should be subset of 1 to 10'``() = shouldFail(fun () -> [ 1..11 ] |> should be (subsetOf [ 1..10 ])) - - [] - member _.``11 should not be subset of 1 to 10 but messages should equal``() = - (fun _ -> [ 11 ] |> should be (subsetOf [ 1..10 ])) - |> fun f -> Assert.Throws(f) - |> fun e -> (e.Expected, e.Actual) - |> should equal ("Is subset of [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]", "[11]") diff --git a/tests/FsUnit.Xunit.Test/equalTests.fs b/tests/FsUnit.Xunit.Test/equalTests.fs index bd5439d1..70bc1eb3 100644 --- a/tests/FsUnit.Xunit.Test/equalTests.fs +++ b/tests/FsUnit.Xunit.Test/equalTests.fs @@ -105,13 +105,6 @@ type ``equal Tests``() = member _.``structural value type should not equal non-equivalent value``() = anImmutableArray |> should not' (equal otherImmutableArray) - [] - member _.``Ok "foo" should fail on equal Ok "bar" but message should be equal``() = - (fun () -> Ok "foo" |> should equal (Ok "bar")) - |> fun f -> Assert.Throws(f) - |> fun e -> (e.Expected, e.Actual) - |> should equal ("Equals Ok \"bar\"", "Ok \"foo\"") - [] member _.``structural comparable type containing non-equivalent structural equatable type fails with correct exception``() = let array1 = ImmutableArray.Create(Uri("https://example.com/1")) diff --git a/tests/FsUnit.Xunit.Test/haveLengthTests.fs b/tests/FsUnit.Xunit.Test/haveLengthTests.fs index fe09b808..e64b90a2 100644 --- a/tests/FsUnit.Xunit.Test/haveLengthTests.fs +++ b/tests/FsUnit.Xunit.Test/haveLengthTests.fs @@ -38,13 +38,6 @@ type ``haveLength tests``() = member _.``Array with 1 item should fail to not have Length 1``() = shouldFail(fun () -> [| 1 |] |> should not' (haveLength 1)) - [] - member _.``Array with 1 item should fail to have Length 2 but messages should equal``() = - (fun () -> [| 1 |] |> should haveLength 2) - |> fun f -> Assert.Throws(f) - |> fun e -> (e.Expected, e.Actual) - |> should equal ("Have Length 2", "[|1|]") - // Seq [] member _.``Seq with 1 item should fail to have Length 1``() = diff --git a/tests/FsUnit.Xunit.Test/shouldFailTests.fs b/tests/FsUnit.Xunit.Test/shouldFailTests.fs index d963e771..3d71e00c 100644 --- a/tests/FsUnit.Xunit.Test/shouldFailTests.fs +++ b/tests/FsUnit.Xunit.Test/shouldFailTests.fs @@ -3,6 +3,7 @@ namespace FsUnit.Test open System open Xunit open FsUnit.Xunit +open Xunit.Sdk type ``shouldFail tests``() = @@ -20,12 +21,12 @@ type ``shouldFail tests``() = [] member _.``shouldFail should throw an exception``() = - (fun () -> shouldFail id) |> should throw typeof + (fun () -> shouldFail id) |> should throw typeof [] member _.``shouldFail should not throw an exception when fail``() = (fun () -> shouldFail(fun () -> [] |> should contain 1)) - |> should not' (throw typeof) + |> should not' (throw typeof) [] member _.``test raising exception``() = diff --git a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs index 64cf463b..09475c0c 100644 --- a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs +++ b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs @@ -16,9 +16,3 @@ type ``should startWith tests``() = member _.``ships should not start with ss``() = "ships" |> should not' (startWith "ss") - [] - member _.``ships should not start with ss but messages should equal``() = - (fun _ -> "ships" |> should startWith "ss") - |> fun f -> Assert.Throws(f) - |> fun e -> (e.Expected, e.Actual) - |> should equal ("ss", "\"ships\"") diff --git a/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs index 938d039c..7900ce98 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs @@ -2,6 +2,7 @@ namespace FsUnit.Typed.Test open FsUnit.Xunit open Xunit +open Xunit.Sdk open FsUnitTyped type ``shouldBeSmallerThan tests``() = @@ -11,7 +12,7 @@ type ``shouldBeSmallerThan tests``() = [] member _.``10 should not be less than 10``() = - (fun () -> 10 |> shouldBeSmallerThan 10) |> shouldFail + (fun () -> 10 |> shouldBeSmallerThan 10) |> shouldFail [] member _.``10[dot]0 should be less than 10[dot]1``() = @@ -20,5 +21,4 @@ type ``shouldBeSmallerThan tests``() = [] member _.``10[dot]0 should not be less than 10[dot]0``() = (fun () -> 10.0 |> shouldBeSmallerThan 10.0) - |> should throw typeof -//|> shouldFail + |> should throw typeof diff --git a/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs index 34b4a09e..8efcbff5 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs @@ -4,6 +4,7 @@ open System.Collections.Immutable open FsUnit.Xunit open Xunit +open Xunit.Sdk open FsUnitTyped open System @@ -81,12 +82,12 @@ type ``shouldEqual Tests``() = [] member _.``Error "Foo" should equal fails and have same message``() = (fun () -> Error "Foo" |> shouldEqual(Error "Bar")) - |> Assert.Throws + |> Assert.Throws |> fun e -> e.Message |> shouldEqual( sprintf - "Exception of type 'FsUnit.Xunit+MatchException' was thrown.%sExpected: Equals Error \"Bar\"%sActual: Error \"Foo\"" + "Assert.Equal() Failure: Values differ%sExpected: Equals Error \"Bar\"%sActual: Error \"Foo\"" Environment.NewLine Environment.NewLine ) @@ -98,12 +99,12 @@ type ``shouldEqual Tests``() = [] member _.``Error "Foo" should not equal Error "Bar" fails and have same message``() = (fun () -> Error "Foo" |> shouldNotEqual(Error "Foo")) - |> Assert.Throws + |> Assert.Throws |> fun e -> e.Message |> shouldEqual( sprintf - "Exception of type 'FsUnit.Xunit+MatchException' was thrown.%sExpected: not Equals Error \"Foo\"%sActual: Error \"Foo\"" + "Assert.Equal() Failure: Values differ%sExpected: not Equals Error \"Foo\"%sActual: Error \"Foo\"" Environment.NewLine Environment.NewLine ) From 23680eb1d999a9bc81bc7d63f8c0f8a7789d80d3 Mon Sep 17 00:00:00 2001 From: Constantin Tews Date: Fri, 7 Jul 2023 22:50:11 +0200 Subject: [PATCH 3/7] Format file. --- tests/FsUnit.Xunit.Test/shouldStartWithTests.fs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs index 09475c0c..bc651e2c 100644 --- a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs +++ b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs @@ -15,4 +15,3 @@ type ``should startWith tests``() = [] member _.``ships should not start with ss``() = "ships" |> should not' (startWith "ss") - From 9f982533c434844c9427782a64aa9f5486d5d100 Mon Sep 17 00:00:00 2001 From: Constantin Tews Date: Mon, 10 Jul 2023 13:37:30 +0200 Subject: [PATCH 4/7] Change exception when no exception was thrown. --- paket.lock | 2 +- src/FsUnit.Xunit/FsUnit.fs | 10 +++++----- tests/FsUnit.Xunit.Test/shouldFailTests.fs | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/paket.lock b/paket.lock index edc8b9d4..a2dbf3e5 100644 --- a/paket.lock +++ b/paket.lock @@ -21,7 +21,7 @@ NUGET NETStandard.Library (2.0.3) Microsoft.NETCore.Platforms (>= 1.1) Newtonsoft.Json (13.0.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) - NHamcrest (3.2) + NHamcrest (3.3) NuGet.Frameworks (6.6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) NUnit (3.13.3) NETStandard.Library (>= 2.0) diff --git a/src/FsUnit.Xunit/FsUnit.fs b/src/FsUnit.Xunit/FsUnit.fs index 65dd16f4..6a562dbd 100644 --- a/src/FsUnit.Xunit/FsUnit.fs +++ b/src/FsUnit.Xunit/FsUnit.fs @@ -13,8 +13,8 @@ type Xunit.Assert with let description = StringDescription() matcher.DescribeTo(description) - let raiseMatchException(value: string) = - raise(EqualException.ForMismatchedValues(description.ToString(), value, null)) + let raiseEqualException(value: string) = + raise(EqualException.ForMismatchedValues(description.ToString(), value)) match box actual with | :? (unit -> unit) as actualfunc -> @@ -23,8 +23,8 @@ type Xunit.Assert with String.Empty with ex -> ex.ToString()) - |> raiseMatchException - | _ -> $"%A{actual}" |> raiseMatchException + |> raiseEqualException + | _ -> $"%A{actual}" |> raiseEqualException let inline should (f: 'a -> ^b) x (actual: obj) = let matcher = f x @@ -49,7 +49,7 @@ let inline shouldFail(f: unit -> unit) = true if not failed then - raise(EqualException.ForMismatchedValues("Method should fail", "No exception raised", null)) + raise(ThrowsException.ForNoException(f.GetType())) let equalSeq expected = CustomMatchers.equalSeq (fun (e: seq<'a>) (a: seq<'a>) -> Assert.Equal>(e, a)) expected diff --git a/tests/FsUnit.Xunit.Test/shouldFailTests.fs b/tests/FsUnit.Xunit.Test/shouldFailTests.fs index 3d71e00c..036d6b9e 100644 --- a/tests/FsUnit.Xunit.Test/shouldFailTests.fs +++ b/tests/FsUnit.Xunit.Test/shouldFailTests.fs @@ -21,10 +21,15 @@ type ``shouldFail tests``() = [] member _.``shouldFail should throw an exception``() = - (fun () -> shouldFail id) |> should throw typeof + (fun () -> shouldFail id) |> should throw typeof [] - member _.``shouldFail should not throw an exception when fail``() = + member _.``shouldFail should not throw an exception when fail with ThrowsException``() = + (fun () -> shouldFail(fun () -> [] |> should contain 1)) + |> should not' (throw typeof) + + [] + member _.``shouldFail should not throw an exception when fail with EqualException``() = (fun () -> shouldFail(fun () -> [] |> should contain 1)) |> should not' (throw typeof) From 22181c479e54ba9402fe960d5dceadfb87fe171b Mon Sep 17 00:00:00 2001 From: Constantin Tews Date: Tue, 11 Jul 2023 09:51:35 +0200 Subject: [PATCH 5/7] Update old tests with MatchException to new Exception type. --- tests/FsUnit.Xunit.Test/beGreaterThanTests.fs | 6 ++++++ tests/FsUnit.Xunit.Test/beSubsetOfTests.fs | 6 ++++++ tests/FsUnit.Xunit.Test/equalTests.fs | 6 ++++++ tests/FsUnit.Xunit.Test/haveLengthTests.fs | 6 ++++++ tests/FsUnit.Xunit.Test/shouldStartWithTests.fs | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs b/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs index c0dbad1c..d0592c40 100644 --- a/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs +++ b/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs @@ -2,6 +2,7 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit +open Xunit.Sdk type ``be greaterThan tests``() = [] @@ -23,3 +24,8 @@ type ``be greaterThan tests``() = [] member _.``9[dot]2 should not be greater than 9[dot]2``() = 9.2 |> should not' (be greaterThan 9.2) + + [] + member _.``10 should not be greater than 10 and should throw EqualException``() = + (fun () -> 10 |> should be (greaterThan 10)) + |> should throw typeof diff --git a/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs b/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs index c40c5f4c..4719eecf 100644 --- a/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs +++ b/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs @@ -2,6 +2,7 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit +open Xunit.Sdk type ``be subsetOf tests``() = @@ -36,3 +37,8 @@ type ``be subsetOf tests``() = [] member _.``should fail on '1 to 11 should be subset of 1 to 10'``() = shouldFail(fun () -> [ 1..11 ] |> should be (subsetOf [ 1..10 ])) + + [] + member _.``11 should not be subset of 1 to 10 and should throw EqualException``() = + (fun _ -> [ 11 ] |> should be (subsetOf [ 1..10 ])) + |> should throw typeof diff --git a/tests/FsUnit.Xunit.Test/equalTests.fs b/tests/FsUnit.Xunit.Test/equalTests.fs index 70bc1eb3..da001746 100644 --- a/tests/FsUnit.Xunit.Test/equalTests.fs +++ b/tests/FsUnit.Xunit.Test/equalTests.fs @@ -4,6 +4,7 @@ open System open System.Collections.Immutable open Xunit +open Xunit.Sdk open FsUnit.Xunit type AlwaysEqual() = @@ -105,6 +106,11 @@ type ``equal Tests``() = member _.``structural value type should not equal non-equivalent value``() = anImmutableArray |> should not' (equal otherImmutableArray) + [] + member _.``Ok "foo" should fail on equal Ok "bar" and should throw EqualException``() = + (fun () -> Ok "foo" |> should equal (Ok "bar")) + |> should throw typeof + [] member _.``structural comparable type containing non-equivalent structural equatable type fails with correct exception``() = let array1 = ImmutableArray.Create(Uri("https://example.com/1")) diff --git a/tests/FsUnit.Xunit.Test/haveLengthTests.fs b/tests/FsUnit.Xunit.Test/haveLengthTests.fs index e64b90a2..ae1b5b67 100644 --- a/tests/FsUnit.Xunit.Test/haveLengthTests.fs +++ b/tests/FsUnit.Xunit.Test/haveLengthTests.fs @@ -1,6 +1,7 @@ namespace FsUnit.Test open Xunit +open Xunit.Sdk open FsUnit.Xunit type ``haveLength tests``() = @@ -38,6 +39,11 @@ type ``haveLength tests``() = member _.``Array with 1 item should fail to not have Length 1``() = shouldFail(fun () -> [| 1 |] |> should not' (haveLength 1)) + [] + member _.``Array with 1 item should fail to have Length 2 and should throw EqualException``() = + (fun () -> [| 1 |] |> should haveLength 2) + |> should throw typeof + // Seq [] member _.``Seq with 1 item should fail to have Length 1``() = diff --git a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs index bc651e2c..63fc709a 100644 --- a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs +++ b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs @@ -1,6 +1,7 @@ namespace FsUnit.Test open Xunit +open Xunit.Sdk open FsUnit.Xunit type ``should startWith tests``() = @@ -15,3 +16,8 @@ type ``should startWith tests``() = [] member _.``ships should not start with ss``() = "ships" |> should not' (startWith "ss") + + [] + member _.``ships should not start with ss and should throw EqualException``() = + (fun _ -> "ships" |> should startWith "ss") + |> should throw typeof \ No newline at end of file From 2ad23df5a16a37588318d4367203b31c2fedb9ec Mon Sep 17 00:00:00 2001 From: Constantin Tews Date: Tue, 11 Jul 2023 09:53:58 +0200 Subject: [PATCH 6/7] Format file. --- tests/FsUnit.Xunit.Test/shouldStartWithTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs index 63fc709a..19eb700a 100644 --- a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs +++ b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs @@ -20,4 +20,4 @@ type ``should startWith tests``() = [] member _.``ships should not start with ss and should throw EqualException``() = (fun _ -> "ships" |> should startWith "ss") - |> should throw typeof \ No newline at end of file + |> should throw typeof From c52729b5660b6ec9c06fb245d6dc593468c9a701 Mon Sep 17 00:00:00 2001 From: Constantin Tews Date: Tue, 11 Jul 2023 10:29:11 +0200 Subject: [PATCH 7/7] Fix tests with shouldFail. --- tests/FsUnit.Xunit.Test/beSubsetOfTests.fs | 12 ++++-------- tests/FsUnit.Xunit.Test/shouldStartWithTests.fs | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs b/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs index 4719eecf..d0925b2e 100644 --- a/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs +++ b/tests/FsUnit.Xunit.Test/beSubsetOfTests.fs @@ -1,8 +1,9 @@ namespace FsUnit.Test open Xunit -open FsUnit.Xunit open Xunit.Sdk +open FsUnit.Xunit +open FsUnitTyped type ``be subsetOf tests``() = @@ -35,10 +36,5 @@ type ``be subsetOf tests``() = [ 1..10 ] |> should be (subsetOf [ 1..10 ]) [] - member _.``should fail on '1 to 11 should be subset of 1 to 10'``() = - shouldFail(fun () -> [ 1..11 ] |> should be (subsetOf [ 1..10 ])) - - [] - member _.``11 should not be subset of 1 to 10 and should throw EqualException``() = - (fun _ -> [ 11 ] |> should be (subsetOf [ 1..10 ])) - |> should throw typeof + member _.``should fail on '1 to 11 should be subset of 1 to 10' and check if it's EqualException``() = + shouldFail(fun () -> [ 1..11 ] |> should be (subsetOf [ 1..10 ])) diff --git a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs index 19eb700a..fea87085 100644 --- a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs +++ b/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs @@ -3,6 +3,7 @@ namespace FsUnit.Test open Xunit open Xunit.Sdk open FsUnit.Xunit +open FsUnitTyped type ``should startWith tests``() = [] @@ -18,6 +19,5 @@ type ``should startWith tests``() = "ships" |> should not' (startWith "ss") [] - member _.``ships should not start with ss and should throw EqualException``() = - (fun _ -> "ships" |> should startWith "ss") - |> should throw typeof + member _.``ships should not start with ss and check if it's EqualException``() = + shouldFail(fun _ -> "ships" |> should startWith "ss")