Making the untestable testable with Anonymous Methods and Dependency Injection
Posted by: Karl Seguin [MVP],
on 08 May 2009 |
View original | Bookmarked: 0 time(s)
Making the untestable testable with Anonymous Methods and Dependency Injection
It can be frustrating to want to write unit tests, only to hit some code which is rather untestable. Take for example, the following code:
public class MailSender
{
public void SendActivationMail(User user, string activationCode)
{
string body = GetCopyOfActivationBody(); //implementation doesn't matter
body = body.Replace("#NAME#", user.Name).Replace("#CODE#", activationKey).Replace("#EMAIL#",...