nDumbster .Net fake SMTP server

SimpleSmtpServer Class

[This is preliminary documentation and subject to change.]

Dummy SMTP server for testing purposes.

For a list of all members of this type, see SimpleSmtpServer Members.

System.Object
   nDumbster.smtp.SimpleSmtpServer

public class SimpleSmtpServer

Thread Safety

This type is safe for multithreaded operations.

The server create a thread to handle message reception and all access to messages list is protected.

Example

The following examples shows how to use nDumbster and NUnit to test your function sendMessage.

[TestFixture]
public class SimpleSmtpServerTest
{
    SimpleSmtpServer smtpServer;

    [SetUp]
    public void Setup()
    {

        smtpServer = SimpleSmtpServer.Start();

    }

    [TearDown]
    public void TearDown()
    {
        smtpServer.Stop();
    }

    [Test]
    public void SendEmail()
    {
        /// Use you own code 
        sendMessage(25, "sender@here.com", "Test", "Test Body", "receiver@there.com");
        Assert.AreEqual(1, smtpServer.ReceivedEmailCount, "1 mails sent");
        SmtpMessage mail= (SmtpMessage)smtpServer.ReceivedEmail[0];
        Assert.AreEqual("<receiver@there.com>", mail.Headers["To"], "Receiver");
        Assert.AreEqual("<sender@here.com>", mail.Headers["From"], "Sender");
        Assert.AreEqual("Test", mail.Headers["Subject"], "Subject");

        Assert.AreEqual("Test Body", mailUser.Body, "Body");
    }
}

Requirements

Namespace: nDumbster.smtp

Assembly: nDumbster (in nDumbster.dll)

See Also

SimpleSmtpServer Members | nDumbster.smtp Namespace