示例#1
0
        public void ExampleSmtpUnitUsage()
        {
            // Setup
            using (var mockServer = new DummySmtpServer(5000)) // Randomly picked port 5000 here, use whatever value you would normally.
            {
                mockServer.Start();

                // Act
                SendEmail();

                // Assert
                Assert.That(mockServer, Received.Mail(1));
                Assert.That(mockServer, Received.Mail(1).From("*****@*****.**"));
                Assert.That(mockServer, Received.Mail(1).To("*****@*****.**"));
                Assert.That(mockServer, Received.Mail(1).Subject("example mail message"));
                Assert.That(mockServer, Received.Mail(1).BodyContains("lorem ipsum"));

                // Clean up
                mockServer.Stop();
            }
        }