Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset invocations #115

Open
troywweber7 opened this issue Oct 27, 2018 · 2 comments
Open

reset invocations #115

troywweber7 opened this issue Oct 27, 2018 · 2 comments

Comments

@troywweber7
Copy link

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...

@WillEllis
Copy link

WillEllis commented Mar 14, 2019

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();

@reflash
Copy link

reflash commented Apr 27, 2020

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 ... .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants