GithubHelp home page GithubHelp logo

mjnewby / ndumbster Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edenridgway/ndumbster

0.0 2.0 0.0 865 KB

A significantly enhanced version of nDumbster for .Net 4.0

Home Page: http://ndumbster.sourceforge.net/default.html

License: Apache License 2.0

C# 95.80% HTML 1.30% CSS 2.90%

ndumbster's Introduction

Introduction

This is a fork of nDumbster, the Test SMTP server, that was originally hosted at: http://ndumbster.sourceforge.net/default.html. nDumbster is useful in automated tests where instead of having to create a wrapper around the mail sending then providing a mock implementation you actually test the email sending component. The SMTP server keeps the messages in memory so you can query what has been sent.

This version is a signficant improvement over the old version as it now uses OpenPop to parse the mail messages sent to the server. This allows you to check the various MIME parts and attachments. It also provides a much richer way of checking the entire mail message.

Enhancements

Apart from being upgraded to .Net 4.0 the following improvements have been made to the library:

  1. The locking issues that lead to slow test times have been removed by using the ConcurrentQueue
  2. Fixed the race condition issue in the code (sending back an SMTP finished before saving the message) that meant that Assertions made after an SMTP send could fail from time to time.
  3. Generics have been used instead of ArrayLists
  4. Messags are now returned as System.Net.Mail.Messages which allow you to query the various messages parts far more easily, such as:
    • Headers are strongly typed
    • Text versus HTML versions can be extracted and compared
    • Attachment handling actually exists
    • Media Types
    • Lists of TO/CC/BCC email addresses

Example Test

// You would normally do this for the entire test fixture
var server = SimpleSmtpServer.Start();
			
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send("[email protected]", "[email protected]", "This is the subject", "This is the body.");

Assert.AreEqual(1, server.ReceivedEmail.Count());

var email = server.ReceivedEmail.First();

Assert.AreEqual("[email protected]", email.Headers.To.First().Address);
Assert.AreEqual("[email protected]", email.Headers.From.Address);

Assert.AreEqual("text/plain", email.Headers.ContentType.MediaType);

Assert.AreEqual("This is the subject", email.Headers.Subject);
Assert.AreEqual("This is the body.", email.FindFirstPlainTextVersion().GetBodyAsText());

server.Stop();

ndumbster's People

Contributors

edenridgway avatar

Watchers

James Cloos avatar Mark Newbs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.