My question is similar to this one: Should I mock all the dependencies when unit testing?
I understand the benefit of mocking when my code accesses a database or a web service or a file on the file system. Mocking means that if there is an issue that I have no control over e.g. a network issue, then my unit tests will pass - because my code is still correct.
However, say I have some code like this:
public Offer AssignOffer(OfferType offerType, IOfferValueCalculator valueCalculator)
{
DateTime dateExpiring = offerType.CalculateExpirationDate();
int value = valueCalculator.CalculateValue(this, offerType);
var offer = new Offer(this, offerType, dateExpiring, value);
_assignedOffers.Add(offer);
NumberOfActiveOffers++;
return offer;
}
which I took from here: https://github.com/jbogard/presentations/blob/master/WickedDomainModels/After/Model/Member.cs
Is it normal practice to mock the object parameters passed to the method i.e. OfferType and IOfferValueCalculator (interfaces and classes I have written)? These classes were written by me and are in the same project as Member.AssignOffer.
I asked a similar question earlier; however it was closed because opinion based. I have tried to make this question more clearer by providing example code.
My question is also similar to this: When should I mock?.
This: https://lostechies.com/jimmybogard/2011/01/07/putting-mocks-in-their-place/ and this: http://www.taimila.com/blog/ddd-and-testing-strategy/ seem to advise only mocking: "Mock across architecturally significant boundaries, but not within those boundaries".