Skip to content

Instantly share code, notes, and snippets.

@davetheninja
Created September 17, 2009 12:49
Show Gist options
  • Save davetheninja/188473 to your computer and use it in GitHub Desktop.
Save davetheninja/188473 to your computer and use it in GitHub Desktop.
[TestFixture, Category("Email")]
public class When_sending_an_email_message : Specification
{
private EmailSender _emailSender;
private ISmtpServer _smtpServer;
private IBuildEmailBodies _emailBodyLoader;
public override void Given()
{
_smtpServer = CreateStub<ISmtpServer>();
_smtpServer.Expect(a => a.Send(Arg<MailMessage>.Is.Anything));
_emailBodyLoader = CreateStub<IBuildEmailBodies>();
_emailBodyLoader.Expect(a => a.Build(Arg<TestEmailMessage>.Is.Anything)).Return(new EmailBody("", ""));
_emailSender = new EmailSender(_emailBodyLoader, _smtpServer);
}
public override void Because()
{
_emailSender.SendEmail(new TestEmailMessage());
}
[Test]
public void Then_the_email_body_should_be_retrieved()
{
_emailBodyLoader.AssertWasCalled(a => a.Build(Arg<EmailMessageBase>.Is.Anything));
}
[Test]
public void And_the_email_should_be_sent_to_the_user()
{
_smtpServer.Send(Arg<MailMessage>.Is.Anything);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment