public void TestSendThroughProviderSpecified()
        {
            SendMailRequest request = Utility.GetTemplateRequest();

            request.Providers = new List <ProviderInfo>()
            {
                new ProviderInfo {
                    ProviderType = ProviderType.SendGrid, ApiKey = Configuration.SendGridApiKey
                },
            };

            SendMailResult result = SendMailRequestProcessor.ProcessSendMailRequest(request);

            Assert.AreEqual(result.ProviderUsed, ProviderType.SendGrid);
        }
        public void TestFailoverToSecondProvider()
        {
            SendMailRequest request = Utility.GetTemplateRequest();

            request.Providers = new List <ProviderInfo>()
            {
                new ProviderInfo {
                    ProviderType = ProviderType.SendGrid, ApiKey = "IncorrectApiKey"
                },
                new ProviderInfo {
                    ProviderType = ProviderType.MailGun, ApiKey = Configuration.MailGunApiKey
                },
            };

            SendMailResult result = SendMailRequestProcessor.ProcessSendMailRequest(request);

            Assert.AreEqual(result.ProviderUsed, ProviderType.MailGun);
        }
        public void TestFailoverToThirdProvider()
        {
            SendMailRequest request = Utility.GetTemplateRequest();

            // specify incorrect key for two providers, the third one should be used
            request.Providers = new List <ProviderInfo>()
            {
                new ProviderInfo {
                    ProviderType = ProviderType.SendGrid, ApiKey = "IncorrectApiKey"
                },
                new ProviderInfo {
                    ProviderType = ProviderType.MailGun, ApiKey = "IncorrectApiKey"
                },
            };

            SendMailResult result = SendMailRequestProcessor.ProcessSendMailRequest(request);

            Assert.AreEqual(result.ProviderUsed, ProviderType.Mandrill);
        }
        public void TestEmailFormat()
        {
            SendMailRequest request = Utility.GetTemplateRequest();

            // sender with name is accepted
            request.From = @"Test sender <*****@*****.**>";

            // multiple recipients are accepted
            // recipient with name is accepted
            request.To.Add(@"SimpleMail SendingService <*****@*****.**");

            request.Providers = new List <ProviderInfo>()
            {
                new ProviderInfo {
                    ProviderType = ProviderType.SendGrid, ApiKey = Configuration.SendGridApiKey
                },
            };

            SendMailResult result = SendMailRequestProcessor.ProcessSendMailRequest(request);

            Assert.AreEqual(result.ProviderUsed, ProviderType.SendGrid);
        }