Esempio n. 1
0
        public void SendMinimal()
        {
            var mailSender   = new MailSenderStub();
            var mailSettings = new MailSettingsStub();

            var mail = new Mail(mailSender, mailSettings);

            mail.Send(Addressing.Create("*****@*****.**", "lfj"), "Minimal", new {});

            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.From.Address);
            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.To[0].Address);
            Assert.AreEqual("Subject", mailSender.MailMessage.Subject);
            Assert.AreEqual("<html>Html</html>", GetContent(mailSender.MailMessage.AlternateViews[0].ContentStream));
            Assert.AreEqual("Text", GetContent(mailSender.MailMessage.AlternateViews[1].ContentStream));
        }
Esempio n. 2
0
        public void MaliciusCharactersTest()
        {
            var mailSender   = new MailSenderStub();
            var mailSettings = new MailSettingsStub();

            var mail = new Mail(mailSender, mailSettings);

            mail.Send(Addressing.Create("*****@*****.**", "lfj"), "ToReplace",
                      new { SSS = "X", TextStuff = "áűú'\"<script>", some = "áűú'\"<script>" });

            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.From.Address);
            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.To[0].Address);
            Assert.AreEqual("SXS", mailSender.MailMessage.Subject);
            Assert.AreEqual("<html>Ht áűú'\"<script> ml</html>", GetContent(mailSender.MailMessage.AlternateViews[0].ContentStream));
            Assert.AreEqual("Textáűú'\"<script> and more", GetContent(mailSender.MailMessage.AlternateViews[1].ContentStream));
        }
Esempio n. 3
0
        public void SendWithReplacements()
        {
            var mailSender   = new MailSenderStub();
            var mailSettings = new MailSettingsStub();

            var mail = new Mail(mailSender, mailSettings);

            mail.Send(Addressing.Create("*****@*****.**", "lfj"), "ToReplace",
                      new { SSS = "X", TextStuff = "plain text", some = "some html" });

            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.From.Address);
            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.To[0].Address);
            Assert.AreEqual("SXS", mailSender.MailMessage.Subject);
            Assert.AreEqual("<html>Ht some html ml</html>", GetContent(mailSender.MailMessage.AlternateViews[0].ContentStream));
            Assert.AreEqual("Textplain text and more", GetContent(mailSender.MailMessage.AlternateViews[1].ContentStream));
        }
Esempio n. 4
0
        public void SendWithImageAdded()
        {
            var mailSender   = new MailSenderStub();
            var mailSettings = new MailSettingsStub();

            var mail = new Mail(mailSender, mailSettings);

            mail.Send(Addressing.Create("*****@*****.**", "lfj"), "ImageAdded", new {});

            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.From.Address);
            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.To[0].Address);
            Assert.AreEqual("Subject", mailSender.MailMessage.Subject);
            Assert.AreEqual("<html>Html<img src=\"cid:img.jpg\"></img></html>", GetContent(mailSender.MailMessage.AlternateViews[0].ContentStream));
            Assert.AreEqual("Text", GetContent(mailSender.MailMessage.AlternateViews[1].ContentStream));

            Assert.AreEqual(1, mailSender.MailMessage.AlternateViews[0].LinkedResources.Count);
            Assert.AreEqual(5, mailSender.MailMessage.AlternateViews[0].LinkedResources[0].ContentStream.Length);
        }
Esempio n. 5
0
        public void RealSendTest()
        {
            var mailSender   = new MailSenderStub();
            var mailSettings = new MailSettingsStub();

            var mail = new Mail(mailSender, mailSettings);

            mail.Send(Addressing.Create("*****@*****.**", "lfj"), "Activation",
                      new { Name = "username", Url = "http://thriot.io" });

            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.From.Address);
            Assert.AreEqual("*****@*****.**", mailSender.MailMessage.To[0].Address);
            Assert.AreEqual("Thriot - user activation", mailSender.MailMessage.Subject);

            var part0 = GetContent(mailSender.MailMessage.AlternateViews[0].ContentStream);
            var part1 = GetContent(mailSender.MailMessage.AlternateViews[1].ContentStream);

            Assert.IsTrue(part0.Contains("username"));
            Assert.IsTrue(part1.Contains("username"));
            Assert.IsTrue(part0.Contains("a href=\""));
            Assert.IsTrue(part0.Contains("http://thriot.io"));
            Assert.IsTrue(part1.Contains("http://thriot.io"));
        }