Foq is a lightweight-thread-safe mocking class library. It is a common practice to use mock abstract classes and interfaces. The Foq name comes from Moq. If you have used Moq, you will naturally think of what it can do. Foq is mainly used for unit testing for developers of F. It can be used with FsUnit to write some Fluent assertions. It even simplifies unit test settings with AutoFixture.
// Moq from C #
var mock = new Mock<ILoveThisFramework>();
mock.Setup(framework => framework.DownloadExists("2.0.0.0"))
.Returns(true);
ILoveThisFramework lovable = mock.Object;
// Foq from F#
let lovable =
Mock<ILoveThisFramework>()
.Setup(fun framework -> <@ framework.DownloadExists("2.0.0.0") @>)
.Returns(true)
.Create()
Some DEMO references are also provided on CodePlex Official Website:
Greeting
Tea
Candy Shop
Driver
Car insurance
Turtle
You can also visit its official website.
Articles you may be interested in:
Durandal Introduction
CompositeC1 4 released
Hope to help your software development.
Author: Petter Liu
Source: http://www.cnblogs.com/wintersun/
The copyright of this article is shared by the author and the blog Park. You are welcome to repost this article. However, you must retain this statement without the author's consent and provide a clear link to the original article on the article page. Otherwise, you will be held legally liable.
This article is also published in Petter Liu Blog, my independent Blog.