Using Moq and looked at Callback
but I have not been able to find a simple example to understand how to use it.
Do you have a small working snippet whic
On top of the other good answers here, I've used it to perform logic before throwing an exception. For instance, I needed to store all objects that were passed to a method for later verification, and that method (in some test cases) needed to throw an exception. Calling .Throws(...)
on Mock.Setup(...)
overrides the Callback()
action and never calls it. However, by throwing an exception within the Callback, you can still do all of the good stuff that a callback has to offer, and still throw an exception.