So I am playing around with mocking frameworks (Moq) for my unit tests, and was wondering when you should use a mocking framework?
What is the benefit/disadvantage b
There are some rules I use writing unit-tests.
There is an old one article by Martin Fowler Mocks Aren't Stubs.
In first test you use Mock and in the second one you use Stub.
Also I see some design issues that lead to your question.
If it is allowed to remove AkaName
from AkaNames
collection then it is OK to use stub and check state of the person. If you add specific method void RemoveAkaName(string name)
into Person
class then mocks should be used in order to verify its invocation. And logic of RemoveAkaName
should be tested as part of Person
class testing.
I would use stub for product
and mock for repository
for you code.