NUnit Equals Within Constraint

Aug 16, 2011 at 11:14 PM
Edited Aug 16, 2011 at 11:16 PM

Great wrapper for NUnit with use by F#.  Currently using it on a project with great success.

Please consider added the Equals Within constraint for NUnit.

I suggest:

In the FsUnit.Nunit project, FsUnit.fs add:

let equalWithin x y =
  let c = new EqualConstraint(y)

Tests would be:

    [<Test>] member test.
      ``should equal within tolerance`` ()=
          10.1 |> should (equalWithin 0.1) 10.11

    [<Test>] member test.
      ``should fail outside tolerance`` ()=
          shouldFail (fun () ->  10.1 |> should (equalWithin 0.01) 10.4)
Dec 11, 2011 at 4:20 AM

Thanks for this great suggestion. We'll look at adding this in a future release. Also, we will likely be setting up a GitHub project that will make collaboration easier.

Dec 11, 2011 at 2:17 PM


The GitHub project has been created (

Dec 12, 2011 at 5:12 AM

equalWithin has been added.