typemoq
typemoq copied to clipboard
reset invocations
I'm trying to use typemoq in an Angular project to mock up certain behavior and verify calls to Excel API (which isn't available at the time of testing so I need to make use of the dynamic mocking). I use the setup to force relationships between certain objects, but later on down the line when I'm expecting something to be called once, it is actually called 9 times (from previous specs that were run).
How can I mitigate this situation? It seems like I need to be able to reset invocations of a call. However, I don't see this available in the API. Or is there a better way to write setups? I've also tried resetting the mock in question and reinitializing the original setup, but this leads to other problems...
There is a reset call on the mock: https://github.com/florinn/typemoq#reset-mocks E.g.
const mockRouter: TypeMoq.IMock<Router> = TypeMoq.Mock.ofType<Router>();
mockRouter.reset();
There is a reset call on the mock: https://github.com/florinn/typemoq#reset-mocks E.g.
const mockRouter: TypeMoq.IMock<Router> = TypeMoq.Mock.ofType<Router>(); mockRouter.reset();
I'm facing the same problem. The aforementioned reset requires to do the setup again, so it will be something like setup -> call test -> reset -> setup again ... .