I agree with what Bill is saying...If you want to guard against someone calling the Close() method you need to check that it wasn't called. Setting a bool in the catch isn't enough.
...tread carefully though, making sure things weren't called, etc can lead you down a path of overspecification of tests... On Thu, Feb 11, 2010 at 3:14 AM, bill richards <[email protected] > wrote: > Off the top of my head, I would say something like ... > > > WhenFooIsOpenedExclusivelyAndOpenIsCalledOnContainer_ShouldThrowMyNewException > > > and with regards to your *need* to test that Close() was not called : > this is not really required, since the Open() method throws an > exception and Close() is only invoked when an exception is not thrown > (in your original code), however this is not th case if you should > change your try/catch block to include a finally clause, i.e. > > try > { > container.Open(); > } > catch(MyNewExceptionType) > { > exceptionWasThrown = true; > } > finally > { > uut.Close(); > } > > under these circumstances, you will need to assert that Close() was > not called. > > try > { > container.Open(); > } > catch(MyNewExceptionType) > { > exceptionWasThrown = true; > } > > uut.Close(); > > under these circumstances, you will not need to assert that Close() > was not called. > > > On Feb 10, 11:42 pm, Kevinst <[email protected]> wrote: > > Thank you guys. I think I will just live with it. > > > > I would have used that ExpectedException attribute but I have to call > > mock.VerifyAllExpectations() after the exception was thrown to make > > sure no Close was executed.. so I have to catch it I guess? > > The Exception is a custom one.. I just didnt want to overload my > > thread ;-) > > > > What would your new name suggestion be? > > -- > 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]<rhinomocks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. > > -- Tim Barcz Microsoft C# MVP Microsoft ASPInsider http://timbarcz.devlicio.us http://www.twitter.com/timbarcz -- 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.
