2012-06-02 15 views
1

這裏是一個平凡的工作測試:FsUnit和NUnit不使用對象?

module Tests 

open NUnit.Framework 
open FsUnit 

[<TestFixture>] 
type simple()= 
    [<Test>] member test. 
    ``tautology``()= 
      true |> should be True 

我的項目不使用任何F#的OOP國家的特徵 - 我可以寫測試,沒有對象,或者是多麼NUnit的作品?

+0

什麼問題? – leppie

回答

1

FsUnit/NUnit也支持let-bounds。下面是從FsUnit's official announcement一個例子:

module Test.``equalWithin assertions`` 

open NUnit.Framework 
open FsUnit 

[<Test>] 
let ``should equal within tolerance when less than``() = 
    10.09 |> should (equalWithin 0.1) 10.11 

[<Test>] 
let ``should not equal within tolerance``() = 
    10.1 |> should not ((equalWithin 0.001) 10.11) 

使用靜態函數的另一個例子可以在FsUnit's github page找到。