Ejemplo n.º 1
0
        public void GivenValidEmailDetailsAndEmailClientShouldSendEmail()
        {
            TestLogger logger = new TestLogger();
            IDnaSmtpClient client = MockRepository.GenerateMock<IDnaSmtpClient>();

            EmailDetailsToProcess emailDetailsToProcess = new EmailDetailsToProcess();
            emailDetailsToProcess.ID = 1;
            emailDetailsToProcess.Subject = "Subject";
            emailDetailsToProcess.Body = "Email Body";
            emailDetailsToProcess.FromAddress = "*****@*****.**";
            emailDetailsToProcess.ToAddress = "*****@*****.**";

            emailDetailsToProcess.ProcessEmail(client, logger);

            Assert.IsTrue(emailDetailsToProcess.Sent);
            Assert.IsNull(emailDetailsToProcess.LastFailedReason);
        }
Ejemplo n.º 2
0
        public void GivenValidEmailDetailsAndInvalidEmailClientShouldNOTSendEmail()
        {
            TestLogger logger = new TestLogger();
            IDnaSmtpClient client = MockRepository.GenerateMock<IDnaSmtpClient>();

            client.Stub(x => x.SendMessage(null)).Throw(new Exception("No Host Set"));

            EmailDetailsToProcess emailDetailsToProcess = new EmailDetailsToProcess();
            emailDetailsToProcess.ID = 1;
            emailDetailsToProcess.Subject = "Subject";
            emailDetailsToProcess.Body = "Email Body";
            emailDetailsToProcess.FromAddress = "*****@*****.**";
            emailDetailsToProcess.ToAddress = "*****@*****.**";

            emailDetailsToProcess.ProcessEmail(client, logger);

            Assert.IsTrue(emailDetailsToProcess.Sent);
            Assert.IsNull(emailDetailsToProcess.LastFailedReason);
        }