public void SendMessage()
        {
            var emailService = MockRepository.GenerateStub<IEmailService>();
            emailService.Stub(x => x.Send(null));

            var handler = new MessageHandler(
                emailService,
                _application.RootNodeName,
                _application.SubjectRegex,
                _application.BodyRegex,
                SubjectStylesheetPath,
                BodyStylesheetPath);

            var message = new MailMessage(From, To, Subject, Body);
            var originalSubject = message.Subject;
            var originalBody = message.Body;

            handler.HandleMessage(message);

            emailService.AssertWasCalled(x => x.Send(message));

            Assert.NotNull(message.Subject);
            Assert.NotNull(message.Body);

            Assert.Greater(message.Subject.Length, 0);
            Assert.Greater(message.Body.Length, 0);

            Assert.AreNotEqual(originalSubject, message.Subject);
            Assert.AreNotEqual(originalBody, message.Body);
        }
 public Application()
 {
     var application = Manager.Current.Application;
     _handler = new MessageHandler(new EmailService(application.SmtpServer,
                                                    application.SmtpPort),
                                   application.RootNodeName,
                                   application.SubjectRegex,
                                   application.BodyRegex,
                                   application.SubjectStylesheetPath,
                                   application.BodyStylesheetPath);
     _server = new SmtpServer(application.ListenPort, _handler.HandleMessage);
 }