Exemplo n.º 1
0
        public void NoCourses_DoNotSendMail()
        {
            db.Contacts.AddRange(contacts);
            db.SaveChanges();

            _homeController.SendAllMail();
            _fakeClient.Received(0).Send(Arg.Any <MailMessage>());
        }
Exemplo n.º 2
0
        public async Task MailServiceSend()
        {
            await _service.SendMailAsync("Test", "Msg", "*****@*****.**");

            _client
            .Received()
            .SendMailAsync(Arg.Is <MailMessage>(it =>
                                                it.From.Address == "*****@*****.**" &&
                                                it.To[0].Address == "*****@*****.**" &&
                                                it.Subject == "Test" &&
                                                it.Body == "Msg" &&
                                                it.IsBodyHtml &&
                                                it.BodyEncoding == Encoding.UTF8))
            .Wait();
        }
Exemplo n.º 3
0
        public async Task NotifyAsync_ConfigHas3SmtpServersAndFirstOfThemDoesNotWork_SmtpClient3WasNotReceived()
        {
            // Arrange
            _smtpClient1.SendAsync(Arg.Any <MailMessage>()).Throws(new Exception());
            // Act
            await _notificator.NotifyAsync(_emailMessage);

            // Assert
            await _smtpClient3.Received(0).SendAsync(Arg.Any <MailMessage>());
        }
Exemplo n.º 4
0
        public void Given_An_EmailMessage_Should_Invoke_Send_Method_Once()
        {
            // Arrange
            const int expected     = 1;
            var       emailMessage = new EmailMessage();

            // Act
            _sut.Send(emailMessage);

            // Assert
            _smtpClient.Received(expected).Send(Arg.Any <EmailMessage>());
        }