From: nunit-...@googlegroups.com [mailto:nunit-...@googlegroups.com] On Behalf Of RJV
Sent: Tuesday, August 04, 2009 10:48 PM
To: nunit-...@googlegroups.com
Subject: [nunit-discuss] Re: creating a mock of an IDisposable object
Sent: Wednesday, August 05, 2009 4:36 AM
Presumably your test should use Assert.Throws or ExpectedException,
but not both. I haven't used Assert.Throws, but I assume it swallows
the exception, and therefore the ExpectedException condition is not
met and your test fails.
Assert
.Throws(typeof(System.NotImplementedException),(()=>test.Dispose()));JvLooking at your code again, why would you expect the exception to be
thrown? You're calling the method on the mock object, not the real
object, and it's the real object that throws the exception. The mock
will only throw an exception if you tell it to.