Another Rhino Mocks Extension Method to Support Your AAA Style

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

1
2
3
4
public static IMethodOptions when_told_to(this T mock, Action action)
{
     return mock.Expect(action);
}

Here is an example of the usage:

1
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!!

Comments