-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFsUnit.fs
More file actions
50 lines (32 loc) · 1 KB
/
FsUnit.fs
File metadata and controls
50 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module FsUnit
open NUnit.Framework
open NUnit.Framework.Constraints
open System
let should (f : 'a -> #Constraint) x (y : obj) =
let c = f x
let y =
match y with
| :? (unit -> unit) -> box (new TestDelegate(y :?> unit -> unit))
| _ -> y
Assert.That(y, c)
let equal x = new EqualConstraint(x)
let not x = new NotConstraint(x)
let contain x = new ContainsConstraint(x)
let haveLength n = Has.Length.EqualTo(n)
let haveCount n = Has.Count.EqualTo(n)
let be = id
let Null = new NullConstraint()
let Empty = new EmptyConstraint()
let EmptyString = new EmptyStringConstraint()
let NullOrEmptyString = new NullOrEmptyStringConstraint()
let True = new TrueConstraint()
let False = new FalseConstraint()
let sameAs x = new SameAsConstraint(x)
let throw = Throws.TypeOf
let withDecimals (y:int) x =
let scale = Math.Pow(10., float y)
Math.Truncate(x * scale) / scale
let withTwoDecimals x =
withDecimals 2 x
let withThreeDecimals x =
withDecimals 3 x