« Riding the Dark Wave | Main | FixEncoding Pipeline Component v1.0.0.1 ... »
Last week I needed a way to unit-test some code I was about to write that sent notification emails, and ran into SmtpMock. Nifty little bugger. Here's some sample code using it:
[Test]
public void CanSendMailSuccessfully()
{
// set up mocks for config, windsor
MockRepository mocks = CreateMocks();
mocks.ReplayAll();
// start mock SMTPServer
SmtpMock smtpServer = new SmtpMock();
smtpServer.Start();
// call sender
IMailSender sender = new MailSender();
sender.SendReport(new Exception("ExceptionTest"));
// check mock server
mocks.VerifyAll();
smtpServer.Stop();
Assert.AreEqual(1, smtpServer.Sessions.Length);
}
About
Tomas Restrepo is a software developer located in Colombia, South America. His interests include .NET, Connected Systems, PowerShell and lately dynamic programming languages. More...
email: tomas@winterdom.com msn: tomasr@passport.com
Syndicate
Ads
Links
Categories
Statistics
Blogroll
Post Archive
Other
Copyright © 2002-2008, Tomas Restrepo.
Powered by: newtelligence dasBlog 2.1.8139.823