public void EmailTraceListener_System_Flush_Optimal() { using (MockEmailTraceListener target = new MockEmailTraceListener(EmailTraceListenerTests.CurrentUserEmailAddress, "'Should Receive' Listener")) { String message = "This is a test."; target.WriteLine(message); try { // This line should 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()); } }
public void EmailTraceListener_Unit_WriteLine_Optimal() { using (MockEmailTraceListener target = new MockEmailTraceListener()) { String message = "This is a test."; target.WriteLine(message); IEnumerable<String> lines = target.LinesDerived; Assert.AreEqual(1, lines.Count()); Assert.AreEqual(message, lines.Single()); } }
public void EmailTraceListener_Unit_WriteLine_CalledTwice() { using (MockEmailTraceListener target = new MockEmailTraceListener()) { String message1 = "This is a test."; target.WriteLine(message1); String message2 = "This is another test."; target.WriteLine(message2); IEnumerable<String> lines = target.LinesDerived; Assert.AreEqual(2, lines.Count()); Assert.AreEqual(message1, lines.ElementAt(0)); Assert.AreEqual(message2, lines.ElementAt(1)); } }
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()); } }
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); } }
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()); } }