Goals strive to give butts (and not mocks ) for everything, even for static or private methods. The Moles manual says that they are not aimed at the mocking aspect, like other mocking frameworks: they offer isolation, not mockery. If you want to check calls to Mols, you have to make your own way. For instance:
bool called = false; MDisposableObject.Constructor = (@this) => { var mole = new MDisposableObject(@this) { Dispose = () => { Assert.IsFalse(called); called=true; //if you want to call the original implementation: MolesContext.ExecuteWithoutMoles(() => (@this).Dispose()); //or do something else, even nothing } }; };
Only Typemock Isolator (powerful, but expensive) and JustMock Telerik (new simultaneous, as well as not free) allow ridiculous functions for everything.
If you have interfaces, delegates, and a virtual method, use a free fake infrastructure like Moq or RhinoMocks.
Warning about my example: so far I have not found how to call the orignal constructor, I mean something like
var mole = new SDisposable(); (@this) = mole; new MDisposable(mole) {...};
Actually, from what I read on msdn, this is not possible ... I hope the following releases will allow this.
source share