diff --git a/src/FsUnit.Xunit/FsUnitTyped.fs b/src/FsUnit.Xunit/FsUnitTyped.fs index 8f8c29cc..65d904e2 100644 --- a/src/FsUnit.Xunit/FsUnitTyped.fs +++ b/src/FsUnit.Xunit/FsUnitTyped.fs @@ -7,13 +7,13 @@ open FsUnit.Xunit module TopLevelOperators = /// Asserts that `expected` is equal to `actual`. - /// The equality instance on `expected` is used. + /// The equality instance on `expected` is used, if available. [] let shouldEqual<'a> (expected: 'a) (actual: 'a) = - should equal actual expected + should equal expected actual /// Asserts that `expected` is not equal to `actual`. - /// The equality instance on `expected` is used. + /// The equality instance on `expected` is used, if available. [] let shouldNotEqual<'a> (expected: 'a) (actual: 'a) = should not' (equal actual) expected diff --git a/tests/FsUnit.Xunit.Test/equalTests.fs b/tests/FsUnit.Xunit.Test/equalTests.fs index e27684c7..9e0942b7 100644 --- a/tests/FsUnit.Xunit.Test/equalTests.fs +++ b/tests/FsUnit.Xunit.Test/equalTests.fs @@ -61,6 +61,10 @@ type ``equal Tests``() = member __.``reference type should fail to not equal itself``() = anObj |> should equal anObj + [] + member __.``should pass when Equals returns true``() = + anObj |> should equal (box(new AlwaysEqual())) + [] member __.``should fail when Equals returns false``() = anObj |> should not' (equal(NeverEqual())) @@ -69,6 +73,10 @@ type ``equal Tests``() = member __.``should pass when negated and Equals returns false``() = anObj |> should not' (equal(NeverEqual())) + [] + member __.``should fail when negated and Equals returns true``() = + shouldFail(fun () -> anObj |> should not' (equal(box(new AlwaysEqual())))) + [] member __.``should pass when comparing two lists that have the same values``() = [ 1 ] |> should equal [ 1 ]