Ejemplo n.º 1
0
        public void Renders_all()
        {
            // ARRANGE
            var expected = "<strong>bob</strong>";
            var t = new Template();
            t.Content.Subject = "<strong>{{name}}</strong>";
            t.Content.Body = "<strong>{{name}}</strong>";
            t.Content.TextBody = "<strong>{{name}}</strong>";

            t.Content.SummaryBody = "<strong>{{name}}</strong>";
            t.Content.SummaryHeader = "<strong>{{name}}</strong>";
            t.Content.SummaryFooter = "<strong>{{name}}</strong>";
            t.Content.SummarySubject = "<strong>{{name}}</strong>";
            t.Content.SummaryTextBody = "<strong>{{name}}</strong>";
            t.Content.SummaryTextHeader = "<strong>{{name}}</strong>";
            t.Content.SummaryTextFooter = "<strong>{{name}}</strong>";
   
            var r = new HandlebarsRenderer(t);

            // ACT
            var mail = new Models.Mail();
            r.Render(mail, new { name = "bob" });

            // ASSERT
            Assert.AreEqual(expected, mail.Body);
            Assert.AreEqual(expected, mail.Subject);
            Assert.AreEqual(expected, mail.SummaryBody);
            Assert.AreEqual(expected, mail.SummaryFooter);
            Assert.AreEqual(expected, mail.SummaryHeader);
            Assert.AreEqual(expected, mail.SummarySubject);
            Assert.AreEqual(expected, mail.TextBody);
            Assert.AreEqual(expected, mail.SummaryTextBody);
            Assert.AreEqual(expected, mail.SummaryTextFooter);
            Assert.AreEqual(expected, mail.SummaryTextHeader);
        }
Ejemplo n.º 2
0
        public void Sanitized_correctly()
        {
            // ARRANGE
            var expectedBody = "<strong>&lt;b&gt;o&lt;/b&gt;</strong>";
            var expectedText = "<b>o</b>";
            var t = new Template();
            t.Content.Body = "<strong>{{name}}</strong>";
            t.Content.TextBody = "{{{name}}}";
          

            var r = new HandlebarsRenderer(t);

            // ACT
            var mail = new Models.Mail();
            r.Render(mail, new { name = "<b>o</b>" });

            // ASSERT
            Assert.AreEqual(expectedBody, mail.Body);
            Assert.AreEqual(expectedText, mail.TextBody);
        }
Ejemplo n.º 3
0
        public void Renders_Complex()
        {
            // ARRANGE
            var expected = "<strong>alice</strong>";
            var t = new Template();
            t.Content.Body = "<strong>{{name.sub}}</strong>";
            var r = new HandlebarsRenderer(t);

            // ACT
            var mail = new Models.Mail();

            r.Render(mail, new
            {
                name = new
                    {
                        sub = "alice"
                    }
            });

            // ASSERT
            Assert.AreEqual(expected, mail.Body);
        }