About Me


Develop With Passion® - Developer Bootcamp


Another Rhino Mocks extension method to support your AAA style

Written August 30, 2008 at 16:49 MDT Tagged programming

If you want to carry on setting expectations on void methods on your mocks, just use the following method

public static IMethodOptions when_told_to(this T mock, Action action)
     return mock.Expect(action);

Here is an example of the usage:

db_connection.when_told_to(x => x.Open()) .Throw(new Exception());  

Just another small play on words, but I like the readability of it.

Develop With Passion!!