Thorsten Lorenz edited this page Nov 29, 2010 · 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.


    `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>