Пример #1
0
        public void EmailTraceListener_System_Flush_HasNoLines()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener(EmailTraceListenerTests.CurrentUserEmailAddress, "'Should Not Receive' Listener")) {
                try {
                    // This line should NOT generate an e-mail.
                    target.Flush();
                }
                catch (SmtpException ex) {
                    Assert.Inconclusive("SMTP is not enabled on this machine: {0}", ex);
                }

                IEnumerable<String> lines = target.LinesDerived;
                Assert.AreEqual(0, lines.Count());
            }
        }
Пример #2
0
        public void EmailTraceListener_Unit_Write_CalledTwice()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener()) {
                String message1 = "This is a test.";
                target.Write(message1);
                String message2 = "This is another test.";
                target.Write(message2);

                IEnumerable<String> lines = target.LinesDerived;
                Assert.AreEqual(0, lines.Count());
            }
        }
Пример #3
0
        public void EmailTraceListener_Unit_Write_Optimal()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener()) {
                String message = "This is a test.";
                target.Write(message);

                IEnumerable<String> lines = target.LinesDerived;
                Assert.AreEqual(0, lines.Count());
            }
        }
Пример #4
0
        public void EmailTraceListener_Unit_Lines_HasLines()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener()) {

                IEnumerable<String> actual = target.LinesDerived;
                Assert.AreEqual(0, actual.Count());
            }
        }
Пример #5
0
        public void EmailTraceListener_Unit_Lines_HasNoLines()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener()) {
                String message = "This is a test.";
                target.WriteLine(message);

                IEnumerable<String> actual = target.LinesDerived;
                Assert.AreEqual(1, actual.Count());
                Assert.AreEqual(message, actual.Single());
            }
        }
Пример #6
0
 public void EmailTraceListener_Unit_CreateMailSubject_Optimal()
 {
     using (MockEmailTraceListener target = new MockEmailTraceListener()) {
         String actual = target.CreateMailSubjectDerived();
         Assert.IsNotNull(actual);
     }
 }
Пример #7
0
        public void EmailTraceListener_Unit_CreateMailBody_Optimal()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener()) {
                String message1 = "This is a test.";
                String message2 = "This is another test.";
                target.WriteLine(message1);
                target.WriteLine(message2);

                String actual = target.CreateMailBodyDerived();
                StringAssert.Contains(actual, message1);
                StringAssert.Contains(actual, message2);
            }
        }
Пример #8
0
        public void EmailTraceListener_Unit_CreateMailBody_HasNoLines()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener()) {

                String actual = target.CreateMailBodyDerived();
                Assert.AreEqual(String.Empty, actual);
            }
        }
Пример #9
0
        public void EmailTraceListener_System_SendMailMessage_Optimal()
        {
            using (MockEmailTraceListener target = new MockEmailTraceListener(EmailTraceListenerTests.CurrentUserEmailAddress, "'Should Receive' Listener")) {
                String message = "This is a test.";
                target.WriteLine(message);

                Boolean actual = false;
                try {
                    // This line should generate an e-mail.
                    actual = target.SendMailMessageDerived();
                }
                catch (SmtpException ex) {
                    Assert.Inconclusive("SMTP is not enabled on this machine: {0}", ex);
                }
                Assert.AreEqual(true, actual);
                Assert.AreEqual(0, target.LinesDerived.Count());
            }
        }
Пример #10
0
 public void EmailTraceListener_System_SendMailMessage_HasNoLines()
 {
     using (MockEmailTraceListener target = new MockEmailTraceListener(EmailTraceListenerTests.CurrentUserEmailAddress, "'Should Not Receive' Listener")) {
         // This line should NOT generate an e-mail.
         Boolean actual = target.SendMailMessageDerived();
         Assert.AreEqual(false, actual);
         Assert.AreEqual(0, target.LinesDerived.Count());
     }
 }