# Sunday, February 24, 2008
« Always Close Your WCF Proxies | Main | Quote of the Day »

I found myself doing this today with Rhino Mocks:

[TearDown]
public void TearDown()
{
    mocks.ReplayAll();  // ensure replay was called
    mocks.VerifyAll();
}

 

I have a few tests in my fixture that don't use mocks, so forcing those tests to have mocks.ReplayAll() in them is just extra noise.  As it turns out calling Replay multiple times is safe, so tests that use mocks of course have already called ReplayAll, but tests that don't use the mocks can forgo having to call ReplayAll() just to have the tear down method run without error.

In case you didn't know, calling VerifyAll in RhinoMocks will throw an exception if you have previously called Replay.

Comments are closed.