Hi,
I noticed that a test I expected to fail due to unexcerised
expectations was actually succeeeding, I've reduced it down to a
synthetic repro...

                [Test, ExpectedException(typeof(Exception), ExpectedMessage =
"expectedMessage")]
                public void ExceptionTest()
                {
                        var mocks = new MockRepository();
                        using (mocks.Record())
                        {
                                var disposable = 
mocks.StrictMock<IDisposable>();
                                Expect.Call(disposable.Dispose);
                        }
                        using (mocks.Playback())
                        {
                                throw new Exception("expectedMessage");
                        }
                }


this appears to be due to a check in PlaybackModeChanger.Dispose

public void Dispose()
{
    if (!
DisposableActionsHelper.ExceptionWasThrownAndDisposableActionShouldNotBeCalled())
    {
        this.m_repository.VerifyAll();
    }
}

I'm assuming this supression is to do with avoiding the original
exception being eclipsed by the one from verify all?, however in the
ExpectedException test case it would be nice if the behaviour could be
controlled, e.g. a Playback(bool verifyAllOnException).

btw I have a current work around using an extension, something like...
                public static void Playback(this MockRepository mockRepository,
Action action)
                {
                        try
                        {
                                action();
                                mockRepository.VerifyAll();
                        }
                        catch (Exception e)
                        {
                                try
                                {
                                        mockRepository.VerifyAll();
                                }
                                catch (Exception e2)
                                {
                                        throw new 
InvalidOperationException(e2.Message, e);
                                }
                        }
                }

Regards,
Glen.

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to