In C# I used to write
var provider = A.Fake<ITimeProvider>();
A.CallTo(() => provider.Fetch()).ReturnsLazily(call => data[0]);
container.Register(() => provider);
to capture calls to Fetch()
.
When I've tried the same with F#
let provider = A.Fake<ITimeProvider>()
A.CallTo(fun () -> provider.Fetch()).ReturnsLazily(fun call -> data.[0]) |> ignore
container.Register(fun () -> provider)
the test fails with
Test Error : ....Test
System.ArgumentException : The specified object is not recognized as a fake object.
at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a](Result`1 res)
at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout)
at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken)
...
It looks like for F# it should be defined a bit differently. Have you some idea how?