VS2015 Ultimate CTP 用の NUnit テスト アダプターを使用して、FsUnit と NUnit を使用して F# で単体テストを作成しています。モジュール メンバーが null であるという奇妙な問題に遭遇しました。
これはコードの問題ですか、それともテストの実行方法ですか?
のシグネチャFoo.SpecificFooStrategy.create
をunit -> FooStrategy
( let create = fun () -> ...
) に変更して as を呼び出してみましたが、うまくいきませFoo.SpecificFooStrategy.create ()
ん。
コード
namespace Foo
// FooStrategy.fs
module FooStrategy =
type FooStrategy =
| FooStrategy of A * B
with
member x.A =
match x with
| FooStrategy(a, _) -> a
member x.B =
match x with
| FooStrategy(_, b) -> b
let create a b = FooStrategy(a, b)
// SpecificFooStrategy.fs
module SpecificFooStrategy =
let private a = // ...
let private b = // ...
let create =
FooStrategy.create a b
テスト
namespace Foo.Tests
[<TestFixture>]
module SpecificFooStrategyTests =
[<Test>]
let ``foo is something`` ()=
let strategy = Foo.SpecificFooStrategy.create
strategy // strategy is null here
|> An.operationWith strategy
|> should equal somethingOrOther