I tried using Rhino Mocks with F # code, and the following code was problematic:
let service = MockRepository.GenerateMock<IMyService>()
service.Stub(s => s.Name).Return("Service");
This was not a surprise since Stub is not part of the IMyService interface, it is a C # extension method that defines Rhino Mocks.
Too much changed code works:
let service = MockRepository.GenerateMock<IMyService>()
RhinoMocksExtensions.Stub<IMyService, string>(service, fun s -> s.Name).Return("Service");
However, it would be nice to define an extension method in F #, but then it will be a parameterized generalized extension method, which will take a tuple. I tried varios syntax, but with no luck. I did not find information on whether this is supported in F # or not. If anyone knows, please let me know.
source
share