Inspired by Castle's EmailTemplateService.
Inheritance: IEmailTemplateService
        public void CanRenderMessage()
        {
            string subject = "this line is subject";
            string body = "Here is message body...";
            var viewStream = new MemoryStream(Encoding.UTF8.GetBytes(subject + Environment.NewLine + body));
            var viewReader = MockRepository.GenerateMock<IViewStreamReader>();
            viewReader.Expect(x => x.GetViewStream(null, null, null)).IgnoreArguments().Return(viewStream);

            _service = new EmailTemplateService(viewReader);
            var message = _service.RenderMessage("foo", new EmailMetadata("*****@*****.**", "*****@*****.**"), _controllerContext);

            Assert.That(message, Is.Not.Null);
            Assert.That(message.Subject, Is.EqualTo(subject));
            Assert.That(message.Body, Is.EqualTo(body));
            Assert.That(message.IsBodyHtml, Is.True, "Emails are HTML by default - plain text should be explicitly set in metadata.");
        }
 public void Setup()
 {
     _controllerContext = new ControllerContext { HttpContext = MvcMockHelpers.DynamicHttpContextBase() };
     _service = new EmailTemplateService();
 }
        public void Setup()
        {
            MvcViewEngines.Engines.Clear();
            MvcViewEngines.Engines.Add(MockRepository.GenerateMock<IViewEngine>());

            _controllerContext = new ControllerContext
            {
                HttpContext = MvcMockHelpers.DynamicHttpContextBase(),
                Controller = MockRepository.GenerateStub<ControllerBase>()
            };

            _service = new EmailTemplateService();

            Response.Stub(x => x.Filter).PropertyBehavior();
            Response.Expect(x => x.ContentEncoding).Return(Encoding.UTF8);
        }