Skip to content

Commit

Permalink
Apply suggestions from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptnCodr committed Dec 20, 2023
1 parent d7fc3dc commit 3651a5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/FsUnit.NUnit/CustomConstraints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ module CustomConstraints =
let result = Common.isOfCase this.Expected actual
ConstraintResult(this, actual, result)
else
failwith "Value (not expression) is not a union case."
failwith $"Value (not expression) is not a union case. Got a {actual.GetType().Name}."
8 changes: 4 additions & 4 deletions src/FsUnit.Xunit/CustomMatchers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ let instanceOfType<'a> =
let contain expected =
let matches(actual: obj) =
match actual with
| :? list<_> as l -> l |> List.exists(fun i -> i = expected)
| :? array<_> as a -> a |> Array.exists(fun i -> i = expected)
| :? seq<_> as s -> s |> Seq.exists(fun i -> i = expected)
| :? IEnumerable as e -> e |> Seq.cast |> Seq.exists(fun i -> i = expected)
| :? list<_> as l -> l |> List.exists((=) expected)
| :? array<_> as a -> a |> Array.exists((=) expected)
| :? seq<_> as s -> s |> Seq.exists((=) expected)
| :? IEnumerable as e -> e |> Seq.cast |> Seq.exists((=) expected)
| _ -> false

CustomMatcher<obj>($"Contains %A{expected}", Func<_, _> matches)
Expand Down
2 changes: 1 addition & 1 deletion tests/FsUnit.NUnit.Test/beOfCaseTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ``be ofCase tests``() =
[<Test>]
member _.``Given a non-union case as value argument throws an exception``() =
(fun () -> 5 |> should not' (be ofCase <@ Second 5 @>) |> ignore)
|> should (throwWithMessage "Value (not expression) is not a union case.") typeof<System.Exception>
|> should (throwWithMessage "Value (not expression) is not a union case. Got a Int32.") typeof<System.Exception>

[<Test>]
member _.``None should be ofCase None``() =
Expand Down

0 comments on commit 3651a5d

Please sign in to comment.