There are two specific types of test doubles, namely stubs and mocks. A stub is a least effort implementation of an abstract class or interface. Sometimes, it is prepared with some stub data, meaning data that is necessary in order to run our tests.
A mock is also a test double, but it will record any interaction and be able to answer asserts on those interactions. You can ask the mock questions such as: was the
GetUsers() method called with the
ID 42 parameter? And in this way, you can verify the interactions of an isolated unit with its outside world.
There are many .NET mocking frameworks that would work well with F#, like Rhino Mocks, Moq, and NMock. Foq is, however, one framework that is specific to F# and uses its code quotations, as we've already seen with Unquote.
You can install Foq directly to your project from the NuGet Package Manager, as shown in the following screenshot: