public EmailNotificatorTests()
        {
            _smtpClientFactory  = Substitute.For <ISmtpClientFactory>();
            _mailSettingsConfig = MailSettingsConfigFake.Generate();

            _mailMessageFactory = Substitute.For <IMessageFactory <MailMessageCreateRequest, MailMessage> >();
            _notificator        = new EmailNotificator(_smtpClientFactory, _mailSettingsConfig, _mailMessageFactory);

            var recipients = new List <string>()
            {
                _faker.Internet.Email(),
            };

            _emailMessage = new EmailMessage("from", recipients, "subject", "body");

            var smtpServerConfig1 = SmtpServerConfigFake.Generate();
            var smtpServerConfig2 = SmtpServerConfigFake.Generate();
            var smtpServerConfig3 = SmtpServerConfigFake.Generate();

            _mailSettingsConfig.Smtp.Servers = new List <SmtpServerConfig>()
            {
                smtpServerConfig1, smtpServerConfig2, smtpServerConfig3
            };

            _smtpClient1 = Substitute.ForPartsOf <FakeSmtpClient>(smtpServerConfig1.Host);
            _smtpClient2 = Substitute.ForPartsOf <FakeSmtpClient>(smtpServerConfig2.Host);
            _smtpClient3 = Substitute.ForPartsOf <FakeSmtpClient>(smtpServerConfig3.Host);

            _smtpClientFactory.Create(smtpServerConfig1).Returns(_smtpClient1);
            _smtpClientFactory.Create(smtpServerConfig2).Returns(_smtpClient2);
            _smtpClientFactory.Create(smtpServerConfig3).Returns(_smtpClient3);
        }
        public EmailNotificatorTests(ITestOutputHelper output)
        {
            _output = output;
            var senderAddress           = "*****@*****.**";
            var senderName              = "notif-test";
            var mailhogSmtpServerConfig = new SmtpServerConfig()
            {
                Host          = "localhost",
                Port          = 25,
                SenderName    = senderName,
                SenderAddress = senderAddress
            };
            var mailSettingsConfig = new MailSettingsConfig()
            {
                Smtp = new MailSettingsConfig.SmtpConfig()
                {
                    Servers = new List <SmtpServerConfig>()
                    {
                        mailhogSmtpServerConfig
                    }
                }
            };

            var toList  = new List <string>();
            var subject = "Test subject";
            var body    = "Test body";

            _emailMessage = new EmailMessage(toList, subject, body);

            var smtpClientFactory  = new SmtpClientWithoutSslFactory();
            var mailMessageFactory = new MailMessageFactory();

            _notificator = new EmailNotificator(smtpClientFactory, mailSettingsConfig, mailMessageFactory);
        }
Exemple #3
0
 public EmailNotificator(ISmtpClientFactory smtpClientFactory,
                         MailSettingsConfig mailSettingsConfig,
                         IMessageFactory <MailMessageCreateRequest, MailMessage> mailMessageFactory)
 {
     _smtpClientFactory  = smtpClientFactory;
     _mailSettingsConfig = mailSettingsConfig;
     _mailMessageFactory = mailMessageFactory;
 }
Exemple #4
0
 public MailSettingsConfigTests()
 {
     _config = new MailSettingsConfig();
 }
 public static MailSettingsConfig HasServers(this MailSettingsConfig config, int serversCount)
 {
     config.Smtp.Servers = SmtpServerConfigFake.Generate(serversCount);
     return(config);
 }