Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Enable substring checks https://github.com/fsprojects/FsUnit/pull/45
* Fixed assertion message for NUnit equal constraint - https://github.com/fsprojects/FsUnit/pull/60
* Added support of `shouldFail` operator for xUnit, MsTest and MbUnit - https://github.com/fsprojects/FsUnit/pull/64
* Added support of `instanceOfType` operator for xUnit, MsTest and MbUnit -
* Added support of `instanceOfType` operator for xUnit, MsTest and MbUnit - https://github.com/fsprojects/FsUnit/pull/65
* Added support of `Empty` operator for xUnit, MsTest and MbUnit -

### 1.3.1.0 - 26 July 2015
* Bump NUnit version up to 2.6.4
Expand Down
2 changes: 1 addition & 1 deletion docs/content/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Operators comparison across frameworks
| Operator | NUnit | xUnit | MSTest | MbUnit |
|------------------------|:-----:|:-----:|:------:|:------:|
| `Null` | + | + | + | + |
| `Empty` | + | | | |
| `Empty` | + | + | + | + |
| `EmptyString` | + | + | + | + |
| `NullOrEmptyString` | + | + | + | + |
| `True` | + | + | + | + |
Expand Down
2 changes: 2 additions & 0 deletions src/FsUnit.MbUnit/FsUnit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ let be = CustomMatchers.be

let Null = CustomMatchers.Null

let Empty = CustomMatchers.Empty

let EmptyString = CustomMatchers.EmptyString

let NullOrEmptyString = CustomMatchers.NullOrEmptyString
Expand Down
2 changes: 2 additions & 0 deletions src/FsUnit.MsTestUnit/FsUnit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ let be = CustomMatchers.be

let Null = CustomMatchers.Null

let Empty = CustomMatchers.Empty

let EmptyString = CustomMatchers.EmptyString

let NullOrEmptyString = CustomMatchers.NullOrEmptyString
Expand Down
9 changes: 9 additions & 0 deletions src/FsUnit.Xunit/CustomMatchers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ let be = id

let Null = Is.Null()

let Empty = CustomMatcher<obj>("A non empty", fun o ->
match o with
| :? string as s -> s.Trim() = ""
| :? list<_> as l -> List.isEmpty l
| :? array<_> as a -> Array.isEmpty a
| :? seq<_> as s -> Seq.isEmpty s
| :? System.Collections.IEnumerable as e -> e |> Seq.cast |> Seq.isEmpty
| _ -> false)

let EmptyString = CustomMatcher<obj>("A non empty string", fun s -> (string s).Trim() = "")

let NullOrEmptyString = CustomMatcher<obj>("A not empty or not null string", fun s -> String.IsNullOrEmpty(unbox s))
Expand Down
2 changes: 2 additions & 0 deletions src/FsUnit.Xunit/FsUnit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ let be = CustomMatchers.be

let Null = CustomMatchers.Null

let Empty = CustomMatchers.Empty

let EmptyString = CustomMatchers.EmptyString

let NullOrEmptyString = CustomMatchers.NullOrEmptyString
Expand Down
37 changes: 31 additions & 6 deletions tests/FsUnit.MbUnit.Test/beEmptyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,50 @@ open NHamcrest.Core
type ``be Empty tests`` ()=
[<Test>] member test.
``empty List should be Empty`` ()=
[].IsEmpty |> should be True
[] |> should be Empty

[<Test>] member test.
``non-empty List should fail to be Empty`` ()=
shouldFail (fun () -> [1] |> should be Empty)

[<Test>] member test.
``non-empty List should not be Empty`` ()=
[1].IsEmpty |> should not' (be True)
[1] |> should not' (be Empty)

[<Test>] member test.
``empty List should fail to not be Empty`` ()=
shouldFail (fun () -> [] |> should not' (be Empty))

[<Test>] member test.
``empty Array should be Empty`` ()=
[||] |> Array.isEmpty |> should be True
[||] |> should be Empty

[<Test>] member test.
``non-empty Array should fail to be Empty`` ()=
shouldFail (fun () -> [|1|] |> should be Empty)

[<Test>] member test.
``non-empty Array should not be Empty`` ()=
[|1|] |> Array.isEmpty |> should not' (be True)
[|1|] |> should not' (be Empty)

[<Test>] member test.
``empty Array should fail to not be Empty`` ()=
shouldFail (fun () -> [||] |> should not' (be Empty))

[<Test>] member test.
``empty Seq should be Empty`` ()=
Seq.empty |> Seq.isEmpty |> should be True
Seq.empty |> should be Empty

[<Test>] member test.
``non-empty Seq should fail to be Empty`` ()=
shouldFail (fun () -> seq { yield 1 } |> should be Empty)

[<Test>] member test.
``non-empty Seq should not be Empty`` ()=
seq { yield 1 } |> Seq.isEmpty |> should not' (be True)
seq { yield 1 } |> should not' (be Empty)

[<Test>] member test.
``empty Seq should fail to not be Empty`` ()=
shouldFail (fun () -> Seq.empty |> should not' (be Empty))


36 changes: 30 additions & 6 deletions tests/FsUnit.MsTest.Test/beEmptyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,49 @@ open NHamcrest.Core
type ``be Empty tests`` ()=
[<TestMethod>] member test.
``empty List should be Empty`` ()=
[].IsEmpty |> should be True
[] |> should be Empty

[<TestMethod>] member test.
``non-empty List should fail to be Empty`` ()=
shouldFail (fun () -> [1] |> should be Empty)

[<TestMethod>] member test.
``non-empty List should not be Empty`` ()=
[1].IsEmpty |> should not' (be True)
[1] |> should not' (be Empty)

[<TestMethod>] member test.
``empty List should fail to not be Empty`` ()=
shouldFail (fun () -> [] |> should not' (be Empty))

[<TestMethod>] member test.
``empty Array should be Empty`` ()=
[||] |> Array.isEmpty |> should be True
[||] |> should be Empty

[<TestMethod>] member test.
``non-empty Array should fail to be Empty`` ()=
shouldFail (fun () -> [|1|] |> should be Empty)

[<TestMethod>] member test.
``non-empty Array should not be Empty`` ()=
[|1|] |> Array.isEmpty |> should not' (be True)
[|1|] |> should not' (be Empty)

[<TestMethod>] member test.
``empty Array should fail to not be Empty`` ()=
shouldFail (fun () -> [||] |> should not' (be Empty))

[<TestMethod>] member test.
``empty Seq should be Empty`` ()=
Seq.empty |> Seq.isEmpty |> should be True
Seq.empty |> should be Empty

[<TestMethod>] member test.
``non-empty Seq should fail to be Empty`` ()=
shouldFail (fun () -> seq { yield 1 } |> should be Empty)

[<TestMethod>] member test.
``non-empty Seq should not be Empty`` ()=
seq { yield 1 } |> Seq.isEmpty |> should not' (be True)
seq { yield 1 } |> should not' (be Empty)

[<TestMethod>] member test.
``empty Seq should fail to not be Empty`` ()=
shouldFail (fun () -> Seq.empty |> should not' (be Empty))

37 changes: 31 additions & 6 deletions tests/FsUnit.Xunit.Test/beEmptyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,50 @@ open NHamcrest.Core
type ``be Empty tests`` ()=
[<Fact>] member test.
``empty List should be Empty`` ()=
[].IsEmpty |> should be True
[] |> should be Empty

[<Fact>] member test.
``non-empty List should fail to be Empty`` ()=
shouldFail (fun () -> [1] |> should be Empty)

[<Fact>] member test.
``non-empty List should not be Empty`` ()=
[1].IsEmpty |> should not' (be True)
[1] |> should not' (be Empty)

[<Fact>] member test.
``empty List should fail to not be Empty`` ()=
shouldFail (fun () -> [] |> should not' (be Empty))

[<Fact>] member test.
``empty Array should be Empty`` ()=
[||] |> Array.isEmpty |> should be True
[||] |> should be Empty

[<Fact>] member test.
``non-empty Array should fail to be Empty`` ()=
shouldFail (fun () -> [|1|] |> should be Empty)

[<Fact>] member test.
``non-empty Array should not be Empty`` ()=
[|1|] |> Array.isEmpty |> should not' (be True)
[|1|] |> should not' (be Empty)

[<Fact>] member test.
``empty Array should fail to not be Empty`` ()=
shouldFail (fun () -> [||] |> should not' (be Empty))

[<Fact>] member test.
``empty Seq should be Empty`` ()=
Seq.empty |> Seq.isEmpty |> should be True
Seq.empty |> should be Empty

[<Fact>] member test.
``non-empty Seq should fail to be Empty`` ()=
shouldFail (fun () -> seq { yield 1 } |> should be Empty)

[<Fact>] member test.
``non-empty Seq should not be Empty`` ()=
seq { yield 1 } |> Seq.isEmpty |> should not' (be True)
seq { yield 1 } |> should not' (be Empty)

[<Fact>] member test.
``empty Seq should fail to not be Empty`` ()=
shouldFail (fun () -> Seq.empty |> should not' (be Empty))