Moq --. Net mocking Library

Source: Internet
Author: User

MoqIs designed and developed for. Net by leveraging the features of. Net 3.5, such as the LINQ Expression Tree and lambda expressions.Mocking Library. Its goal is to integrate mocking with existing unit tests in a natural way, making it simpler and more intuitive, to prevent developers from being forced to rewrite the testing or learning the mock framework that requires a large amount of recording/playback. The objective of Moq is to help write testsCodeBut does not use the mocking framework. Moq's design principle is to acquire good refactoring capabilities with a very low threshold.

 

Moq provides the following features:

    • Strong type: it does not support setting expectation (expectations) using strings, nor does it support returning values and constraints of the object type.
    • Perfect Integration with vs: all features fully support vs intelligent sensing, from setting expectations to specifying parameters and return values of referenced methods.
    • You no longer need to learn about recording/playing. You only need to build your own mock, set your expectations, call it, and verify them selectively.
    • As described in the first three features, this leaves its learning curve extremely low, and in most cases you don't even need to read the document.
    • Fine-grained control is better than using a simple mockbehavior enumerator to implement mock for behavior (no longer need to learn the theoretical differences between mock, Stub, fake, and dynamic mock)
    • Mock can be performed on interfaces and Classes
    • Overload expectation: You can set the default expectation for the mock method during global settings. You can reload the mock method as needed.
    • Input Construction parameters to the Mock class
    • Use mock to intercept and trigger events

Moq isOpen SourceAnd look forward to more people's contributions, its source code,Binary PackageAndGetting startedAll are hosted on Google Code.

Daniel cazzulino is the main Maintainer of Moq. He has releasedA series of articlesTo illustrate why Moq is created, and provides several good examples to demonstrate how to use Moq effectively.

 

Connection: http://www.infoq.com/cn/news/2008/08/Moq

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.