How to Use Rhino Mocks/Introduction

Basic Usage
1. Create a mock repository:

2. Add a mock object to the repository:

If you're using C# 2.0, you may use the generic version and avoid upcasting:

3. "Record" the methods that you expect to be called on the mock object:

Note that the parameter values provided in these calls represent those values we expect our mock to be called with. Similarly, the return value represents the value that the mock will return when this method is called.

You may expect a method to be called multiple times:

4. Set the mock object to a "Replay" state where, as called, it will replay the operations just recorded.

5. Invoke code that uses the mock object.

6. Check that all calls were made to the mock object.