Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1.96 KB

File metadata and controls

51 lines (40 loc) · 1.96 KB

FsUnit.Light

Minimalistic version of FsUnitTyped for xUnit, NUnit ans MSTest.

It provides zero-cost abstraction over native assertions with no dependency on FsUnit. You can find some considerations in the initial issue.

Usage

1 |> shouldEqual 1 // pass
1 |> shouldNotEqual 2 // pass
[2] |> shouldContain 1 // pass
[] |> shouldNotContain 1 // pass
"Hello" |> shouldContainText "He" // pass
"Hello" |> shouldNotContainText "He" // fail
[] |> shouldBeEmpty // pass
[1] |> shouldHaveLength 1 // pass
2 |> shouldBeGreaterThan 1 // pass
1 |> shouldBeSmallerThan 2 // pass
(fun () -> null |> Array.sortInPlace) |> shouldFail<ArgumentNullException> // pass
(fun () -> failwith "error") |> shouldFailWithMessage "error" // pass
task { raise <| ArgumentNullException() } |> shouldFailTask<ArgumentNullException> // pass (should be awaited)
task { failwith "error" } |> shouldFailTaskWithMessage "error" // pass (should be awaited)
[1;2] |> shouldEquivalent [2;1] // pass
Item(Id="1") |> shouldEquivalent (Item(Id ="1")) // pass

You can also find examples in the real tests

Migration from FsUnitTyped

You need to change

open FsUnitTyped

to

open FsUnit.Light

Nuget Packages:

Framework Package
xUnit FsUnit.Light.xUnit
NUnit FsUnit.Light.NUnit
MSTest FsUnit.Light.MSTest