예제 #1
0
        public async Task NoSendsGreetingWhenNoBirthdays()
        {
            File(fileConfiguration.FilePath, Header(), Employee("Mary", "1982/11/08", "*****@*****.**"));

            await app.Run(Date("11/09/2020"));

            ReceivedMail.FromAll(smtpServer)
            .Should()
            .BeEmpty();
        }
        public async Task SendBirthday()
        {
            using var smtpServer   = SimpleSmtpServer.Start(smtpConfiguration.Port);
            using var notification = new SmtpGreetingsNotification(smtpConfiguration);

            await notification.SendBirthday(new[]
            {
                new EmailInfo("foo", "*****@*****.**"),
            });

            ReceivedMail.FromAll(smtpServer)
            .Should()
            .BeEquivalentTo(new ReceivedMail(smtpConfiguration.Sender,
                                             "*****@*****.**",
                                             "Happy birthday!",
                                             "Happy birthday, dear foo!"));
        }
        public async Task ServerUnreachableDuringSend()
        {
            using var smtpServer   = SimpleSmtpServer.Start(smtpConfiguration.Port);
            using var notification = new SmtpGreetingsNotification(smtpConfiguration,
                                                                   new StopServerAfterOneSend(smtpServer));

            var ex = await Assert.ThrowsAsync <SmtpException>(() =>
                                                              notification.SendBirthday(new[]
            {
                new EmailInfo("foo", "*****@*****.**"),
                new EmailInfo("bar", "*****@*****.**"),
            }));

            Assert.Equal(SmtpStatusCode.GeneralFailure, ex.StatusCode);

            ReceivedMail.FromAll(smtpServer)
            .Should()
            .BeEquivalentTo(new ReceivedMail(smtpConfiguration.Sender,
                                             "*****@*****.**",
                                             "Happy birthday!",
                                             "Happy birthday, dear foo!"));
        }
예제 #4
0
        public async Task SendManyGreetingsWhenManyBirthdays()
        {
            File(fileConfiguration.FilePath,
                 Header(),
                 Employee("Matteo", "1982/09/11", "*****@*****.**"),
                 Employee("John", "1982/10/08", "*****@*****.**"),
                 Employee("Mary", "1975/09/11", "*****@*****.**"));

            await app.Run(Date("11/09/2020"));

            ReceivedMail.FromAll(smtpServer)
            .Should()
            .BeEquivalentTo(
                new ReceivedMail(smtpConfiguration.Sender,
                                 "*****@*****.**",
                                 "Happy birthday!",
                                 "Happy birthday, dear Mary!"),
                new ReceivedMail(smtpConfiguration.Sender,
                                 "*****@*****.**",
                                 "Happy birthday!",
                                 "Happy birthday, dear Matteo!")
                );
        }