|
From: Colin K. <col...@us...> - 2004-06-24 06:36:47
|
Update of /cvsroot/nmock/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2994 Modified Files: index.html Log Message: - Modfied to include a formatted version of Joe's email docs for NMock. Index: index.html =================================================================== RCS file: /cvsroot/nmock/website/index.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.html 24 Jun 2004 05:03:29 -0000 1.3 --- index.html 24 Jun 2004 06:36:38 -0000 1.4 *************** *** 1,4 **** ! <p>NMock is a dynamic mock-object library for .NET. Its purpose is to ! provide a clean API for rapidly creating mock implementations of custom ! objects and verifying that objects interact with them correctly from ! unit tests.</p> \ No newline at end of file --- 1,1280 ---- ! <style type="text/css"> ! <!-- ! .syntax0 { ! color: #000000; [...1256 lines suppressed...] ! Principle, Dependency Injector Pattern). Passing dependencies in from the outside decouples class under test from a ! particular implementation of the dependency (a good practice in general), making it easier to mock.</p> ! ! <p><span style="font-weight: bold;">Return values</span>: If the method being mocked returns a value or throws an ! exception, you can use ExpectAndReturn() or ExpectAndThrow() to specify what the mock should return. You can also ! use SetupResult() which does not associate an expectation and doesn't care how many times the method is called.</p> ! ! <p><span style="font-weight: bold;">Mocking classes</span>: NMock supports mocking of classes with virtual methods ! as well as interfaces. The merits of when to mock classes and interfaces is a religious debate. However, use of ! interfaces is highly recommended.</p> ! ! <p><span style="font-weight: bold;">Don't mock things you don't own</span>: It's awkward and painful trying to mock ! someone else's API (such as ADO.NET), leading to hard to read tests and assumptions about how the API works. On the ! other hand, mocking your own APIs leads you down the path of creating cleaner interfaces, which can never hurt. If ! dealing with external APIs, create your own clean abstraction suited for your purposes, which you can mock easily. ! For testing the abstraction itself, don't use mocks, use the real thing. This is the opposite of the usage commonly ! associated with using mocks, which usually leads to brittle and cumbersome tests.</p> ! ! <p><span style="font-weight: bold;">PropertyConstraint</span>: Allows you to setup constraints on properties of ! objects.</p> |