Often, a class would not have a direct exit; he manipulates his dependencies, forcing them to do something.
For instance:
internal interface IEmailer
{
void SendEmail();
}
class ReportSender
{
public IEmailer Emailer { get; set; }
public ReportSender(IEmailer emailerToUse)
{
Emailer = emailerToUse;
}
public void SendReport()
{
Emailer.SendEmail();
}
}
Creating an IEmailer layout and making it expect that IEmailer.SendEmail () seems to expose too many internal class functions and makes the test vulnerable. But I cannot think of another way to test this class.
How should we write unit tests for this class?
source
share