diff --git a/src/FsUnit.Xunit/FsUnitTyped.fs b/src/FsUnit.Xunit/FsUnitTyped.fs index 86a21313..8f8c29cc 100644 --- a/src/FsUnit.Xunit/FsUnitTyped.fs +++ b/src/FsUnit.Xunit/FsUnitTyped.fs @@ -6,33 +6,37 @@ open FsUnit.Xunit [] module TopLevelOperators = + /// Asserts that `expected` is equal to `actual`. + /// The equality instance on `expected` is used. [] let shouldEqual<'a> (expected: 'a) (actual: 'a) = - should equal expected actual + should equal actual expected + /// Asserts that `expected` is not equal to `actual`. + /// The equality instance on `expected` is used. [] let shouldNotEqual<'a> (expected: 'a) (actual: 'a) = - expected |> should not' (equal actual) + should not' (equal actual) expected [] - let shouldContain<'a when 'a : equality> (x: 'a) (y: 'a seq) = + let shouldContain<'a when 'a: equality> (x: 'a) (y: 'a seq) = y |> should contain x [] - let shouldBeEmpty<'a> (list: 'a seq) = + let shouldBeEmpty<'a>(list: 'a seq) = list |> should be Empty [] - let shouldNotContain<'a when 'a : equality> (x: 'a) (y: 'a seq) = + let shouldNotContain<'a when 'a: equality> (x: 'a) (y: 'a seq) = if Seq.exists ((=) x) y then failwith $"Seq %A{y} should not contain %A{x}" [] - let shouldBeSmallerThan<'a when 'a : comparison> (x: 'a) (y: 'a) = + let shouldBeSmallerThan<'a when 'a: comparison> (x: 'a) (y: 'a) = should be (lessThan x) y [] - let shouldBeGreaterThan<'a when 'a : comparison> (x: 'a) (y: 'a) = + let shouldBeGreaterThan<'a when 'a: comparison> (x: 'a) (y: 'a) = should be (greaterThan x) y [] diff --git a/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs index 71f699cd..4466030c 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs @@ -5,7 +5,6 @@ open System.Collections.Immutable open FsUnit.Xunit open Xunit open FsUnitTyped -open FsUnit open System type AlwaysEqual() = @@ -85,7 +84,12 @@ type ``shouldEqual Tests``() = |> Assert.Throws |> fun e -> e.Message - |> shouldEqual(sprintf " Expected: Error \"Bar\" or Error \"Bar\"%s But was: Error \"Foo\"%s" Environment.NewLine Environment.NewLine) + |> shouldEqual( + sprintf + "Exception of type 'FsUnit.Xunit+MatchException' was thrown.%sExpected: Equals Error \"Bar\"%sActual: Error \"Foo\"" + Environment.NewLine + Environment.NewLine + ) [] member __.``Error "Foo" should not equal Error "Bar"``() = @@ -97,7 +101,12 @@ type ``shouldEqual Tests``() = |> Assert.Throws |> fun e -> e.Message - |> shouldEqual(sprintf " Expected: not Equals Error \"Foo\"%sActual: Error \"Foo\"%s" Environment.NewLine Environment.NewLine) + |> shouldEqual( + sprintf + "Exception of type 'FsUnit.Xunit+MatchException' was thrown.%sExpected: not Equals Error \"Foo\"%sActual: Error \"Foo\"" + Environment.NewLine + Environment.NewLine + ) [] member this.``structural equality``() =