public void NoReceipient()
        {
            var attachmentFactory = new Mock<IMailAttachmentFactory>();
            var notifier = new Mock<IMessageDispatchNotifier>();
            Exception ex = null;
            notifier.Setup(x => x.Notify(It.IsAny<IMessage>(), false, It.IsAny<Exception>()))
                    .Callback<IMessage, bool, Exception>((x, y, z) => ex = z);

            var dispatcher = new MailMessageDispatcher(attachmentFactory.Object, notifier.Object);

            var message = new Message();

            dispatcher.Send(message);

            Assert.AreEqual(0, smtpServer.ReceivedEmailCount, "Count differs");
            Assert.IsNotNull(ex);
            Assert.AreEqual("A recipient must be specified.", ex.Message);
        }
        public void Send()
        {
            var attachmentFactory = new Mock<IMailAttachmentFactory>();
            var notifier = new Mock<IMessageDispatchNotifier>();

            var dispatcher = new MailMessageDispatcher(attachmentFactory.Object, notifier.Object);

            var source = new TextAttachment
            {
                Name = "Text",
                Content = "Content"
            };

            var attachment = new Attachment(new MemoryStream(Encoding.ASCII.GetBytes("Content")), "Test");
            attachmentFactory.Setup(x => x.CreateAttachement(It.IsAny<IAttachment>())).Returns(attachment);

            var message = new Message
            {
                From = "*****@*****.**",
                FromName = "From",
                BounceAddress = "*****@*****.**",
                Subject = "Subject",
                Text = "Text",
                Html = "Html",
            };
            message.ToAddress.Add("*****@*****.**");
            message.Cc.Add("*****@*****.**");
            message.Bcc.Add("*****@*****.**");
            message.Headers["X-Path"] = "xpath";
            message.Attachments.Add(source);
          
            dispatcher.Send(message);

            Assert.AreEqual(1, smtpServer.ReceivedEmailCount, "Count differs");
            notifier.Verify(x => x.Notify(It.IsAny<IMessage>(), true, null));

            var candidate = smtpServer.ReceivedEmail.First();
            Assert.AreEqual("Subject", candidate.Subject, "Subject differs");
        }