示例#1
0
        public void SendMailSucceeds()
        {
            this.CallBasicModuleInit();

            var response = MailModule.SendMail(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_SENDER_MAIL),
                new[]
            {
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_1),
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_2),
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_3),
            },
                "test",
                "test \\U+1F601",
                "<b>test</b> \\U+1F601");

            Assert.True(JsonConvert.DeserializeObject <Response <string> >(response).IsSuccess);
        }
示例#2
0
        public void SendMailWithAttachmentSucceeds()
        {
            this.CallBasicModuleInit();

            var response = MailModule.SendMail(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_SENDER_MAIL),
                new[]
            {
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_1),
            },
                "test",
                "test",
                "<b>test</b>",
                new[]
            {
                "assets/favicon-32x32.png",
                "assets/fake_log.txt",
            });

            Assert.True(JsonConvert.DeserializeObject <Response <string> >(response).IsSuccess);
        }
示例#3
0
        public void SendMailSucceeds()
        {
            var mock = new Mock <IMailMapper>();

            mock.Setup(
                x => x.SendMail(
                    It.IsAny <string>(),
                    It.IsAny <IEnumerable <string> >(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    null)).Returns("ok");

            mock.Setup(
                x => x.SendMail(
                    It.IsAny <string>(),
                    It.IsAny <IEnumerable <string> >(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <IEnumerable <string> >())).Returns("ok");

            this.CallBasicModuleInit();
            MailModule.MailMapper = mock.Object;

            Assert.True(MailModule.SendMail(
                            "test",
                            new[] { "test" },
                            "test",
                            "test",
                            "test") == "ok");

            Assert.True(MailModule.SendMail(
                            "test",
                            new[] { "test" },
                            "test",
                            "test",
                            "test",
                            new[] { "test" }) == "ok");
        }
示例#4
0
        public void SendMailInputsAreValidated()
        {
            var mock = new Mock <IMailMapper>();

            this.CallBasicModuleInit();
            MailModule.MailMapper = mock.Object;

            Assert.Contains("sender", MailModule.SendMail(
                                string.Empty,
                                new[] { string.Empty },
                                string.Empty,
                                string.Empty,
                                string.Empty));
            Assert.Contains("recipients", MailModule.SendMail(
                                "test",
                                new[] { string.Empty },
                                string.Empty,
                                string.Empty,
                                string.Empty));
            Assert.Contains("subject", MailModule.SendMail(
                                "test",
                                new[] { "test" },
                                string.Empty,
                                string.Empty,
                                string.Empty));
            Assert.Contains("textBody", MailModule.SendMail(
                                "test",
                                new[] { "test" },
                                "test",
                                string.Empty,
                                string.Empty));
            Assert.Contains("htmlBody", MailModule.SendMail(
                                "test",
                                new[] { "test" },
                                "test",
                                string.Empty,
                                string.Empty));
        }