Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

30_EqualityAssertions

Thorsten Lorenz edited this page · 3 revisions

FSharpSpec Equality Assertions

FSharpSpec comes with lots of built in assertions in form of should and shouldn't functions.

should.equal, shouldn't.equal

These methods test for value equality of two objects - no big surprise there.

If one object is null, no exceptions is thrown, but the test will fail if it was not expected to be null.

Examples

    `it "1 + 1 is 2" (1 + 1) should.equal 2`
    `it "1 + 1 is not 3" (1 + 1) shouldn't.equal 2`

should.beSameAs, shouldn't.beSameAs

These methods work like their should.equal counterparts, but test for reference equality of two objects.

should.be, shouldn't be

These methods have two functions

  1. Test for boolean equality (the same as should.equal for booleans).

    Examples it "true is true" true should.be true it "true is not false" true shouldn't.be false

  2. Test if a given object has/has not an expected type

    Example it "'r' is a char" 'r' should.be typeof<char>

Something went wrong with that request. Please try again.