dotnet add package HmxLabs.SmtpUnit --version 0.1.0
NuGet\Install-Package HmxLabs.SmtpUnit -Version 0.1.0
<PackageReference Include="HmxLabs.SmtpUnit" Version="0.1.0" />
paket add HmxLabs.SmtpUnit --version 0.1.0
#r "nuget: HmxLabs.SmtpUnit, 0.1.0"
// Install HmxLabs.SmtpUnit as a Cake Addin #addin nuget:?package=HmxLabs.SmtpUnit&version=0.1.0 // Install HmxLabs.SmtpUnit as a Cake Tool #tool nuget:?package=HmxLabs.SmtpUnit&version=0.1.0
SMTP Unit was written to help facilitate the testing of code that sends email without needing to use a real SMTP server to validate what was sent.
Now of course in your own code you have well defined interfaces and your test code has mocks (of those interfaces) and you don’t need a real SMTP server. Sometime though you need to use a library that doesn’t provide you the ability to do that, or maybe some legacy code, or maybe you just want to integration test your system with something as close to a production configuration as possible. This is meant to help out in all those cases.
It is written as additional constraints to NUnit and as such the idea is to allow you to write test code such as the following:
Assert.That(smtpServer, Received.Mail(1).From("firstname.lastname@example.org")); Assert.That(smtpServer, Received.Mail(1).Subject("Welcome to SMTPUnit")); Assert.That(smtpServer, Received.Mail(1).BodyContains("Aren't automated test so great!"));
See documentation for further details but it is as simple as:
// Setup var mockServer = new DummySmtpServer(); mockServer.Start(); // Act – call your code to send email here // Assert Assert.That(mockServer, Received.Mail(1).From("email@example.com"));
Since it is written as an NUnit constraint, there is a dependency on NUnit. There are no other dependencies if you wish to use SMTPUnit.
The test code for SMTPUnit however also has an additional dependency on HMX Core. This is not needed unless you wish to develop/contribute to SMTPUnit.
Much of the code is documented inline and the XML documentation files are included as part of the downloads. We are looking into hosting MSDN style documentation online but this is not yet available.
An example project is included in the source code also.
HMx Labs Core is Open Source software and is licensed under an MIT style license. This allows use in both free and commercial applications without restriction. The complete licence text is available on the HMx Labs website or here
Contributing, Bug Reports and Support
If you’ve found a bug or thought of a new feature that would be useful feel free to either implement it and raise a pull request for us or if you’d like us to take a look then just get in touch.
Support is provided very much on a best effort only basis and by electronic means (emails, pull requests, bug reports etc) only.
Unless you’re a client of HMx Labs of course, in which case just give us a call!
|Product||Versions Compatible and additional computed target framework versions.|
|.NET Framework||net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed.|
- NUnit (>= 2.6.4 && < 3.0.0)
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.