Rhino Mocks: Void methods using Expect.Call
One of the things that I dislike about Rhino Mocks is the disconnect between methods that return a value and methods that do not. The first are handled quite naturally using Expect.Call() syntax, but the later have to use the LastCall syntax, which is often a cause of confusion.
There is little to be done there, though, that is a (valid) constraint place there by the compiler, can't do much there, right?
Jim Bolla had a different idea, and had a great suggestion, so now we can write this:
IServer mockServer = mocks.CreateMock<IMock>();
Expect.Call(delegate { mockServer.Start(); }).Throw(new InvalidConigurationException());
// rest of the test
It is also a good way to start preparing Rhino Mocks for C# 3.0.
Many thanks to Jim.
Again, the code is in the repository, and will be released soon.