Skip to content

Commit

Permalink
Fix remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Smaug123 committed Apr 3, 2022
1 parent 7845667 commit c01985f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
18 changes: 11 additions & 7 deletions src/FsUnit.Xunit/FsUnitTyped.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,37 @@ open FsUnit.Xunit
[<AutoOpen>]
module TopLevelOperators =

/// Asserts that `expected` is equal to `actual`.
/// The equality instance on `expected` is used.
[<DebuggerStepThrough>]
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.
[<DebuggerStepThrough>]
let shouldNotEqual<'a> (expected: 'a) (actual: 'a) =
expected |> should not' (equal actual)
should not' (equal actual) expected

[<DebuggerStepThrough>]
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

[<DebuggerStepThrough>]
let shouldBeEmpty<'a> (list: 'a seq) =
let shouldBeEmpty<'a>(list: 'a seq) =
list |> should be Empty

[<DebuggerStepThrough>]
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}"

[<DebuggerStepThrough>]
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

[<DebuggerStepThrough>]
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

[<DebuggerStepThrough>]
Expand Down
15 changes: 12 additions & 3 deletions tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ open System.Collections.Immutable
open FsUnit.Xunit
open Xunit
open FsUnitTyped
open FsUnit
open System

type AlwaysEqual() =
Expand Down Expand Up @@ -85,7 +84,12 @@ type ``shouldEqual Tests``() =
|> Assert.Throws<MatchException>
|> 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
)

[<Fact>]
member __.``Error "Foo" should not equal Error "Bar"``() =
Expand All @@ -97,7 +101,12 @@ type ``shouldEqual Tests``() =
|> Assert.Throws<MatchException>
|> 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
)

[<Fact>]
member this.``structural equality``() =
Expand Down

0 comments on commit c01985f

Please sign in to comment.