我正在使用 FsUnit 和 NUnit 用 VS2015 Ultimate CTP 的 NUnit 测试适配器在 F# 中编写单元测试。我遇到了一个奇怪的问题,模块成员为空,我不希望它是。
这是代码的问题,还是测试执行方式的问题?
我尝试将签名更改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