Set up moq unit test multiple times
PhilippCh opened this issue · 2 comments
This is more of a general unit-testing question, but I don't quite know how to deal with it within the zenject context.
Assuming I have a class Service
that is a dependency of my test subject. Within two different test (methods) I want to have Service.GetUsers()
return two different results because I want to test how my subject reacts to them. In regular unit testing with Moq I'd just set up a new mock object every time, but is this possible/feasible with Zenject?
In theory, I should set up the new mock, add it to the DIContainer and re-inject my subject instance, right?
Hi!
It's been two months now that you've posted your question.
And you probably have found your answer yet.
But YES! That's the great part with DI. As you are able to isolate your objects and write tests for them.
You can bind a test double and inject it.
You can also automate the process...
https://github.com/svermeulen/Extenject/blob/master/Documentation/AutoMocking.md
Thanks a lot, that's essentially what I did in the end :)