public static void Send_No_Recipients() { // Arrange var mailService = new MockMailService(); MailMessage message = new MailMessage(); // Act Assert.Throws <ArgumentException>(() => mailService.Send(message)); // Assert }
public static void Send_Has_Recipients_But_All_Empty() { // Arrange var mailService = new MockMailService(); mailService.Recipients = new[] { string.Empty, string.Empty }; MailMessage message = new MailMessage(); // Act Assert.Throws <ArgumentException>(() => mailService.Send(message)); // Assert }
public static void Send_Throws_Exception(Type type) { // Arrange var message = new MailMessage(); var mailService = new MockMailService(); mailService.Recipients = new[] { "*****@*****.**" }; mailService.DispatchMessageThrows = (Exception)Activator.CreateInstance(type); // Act Assert.DoesNotThrow(() => mailService.Send(message)); // Assert Assert.False(mailService.WaitHandle.WaitOne(100)); Assert.True(mailService.ExceptionHandled); }
public static void Send_Has_Recipients_But_Empty() { // Arrange var mailService = new MockMailService(); mailService.Recipients = new[] { "*****@*****.**", string.Empty }; MailMessage message = new MailMessage(); // Act mailService.Send(message); // Assert Assert.Equal(1, message.To.Count); Assert.Equal("*****@*****.**", message.To[0].Address); Assert.True(mailService.WaitHandle.WaitOne()); }
public static void Send_Message_Has_Recipient() { // Arrange var mailService = new MockMailService(); MailMessage message = new MailMessage(); message.To.Add("*****@*****.**"); // Act mailService.Send(message); // Assert Assert.Equal(1, message.To.Count); Assert.Equal("*****@*****.**", message.To[0].Address); Assert.True(mailService.WaitHandle.WaitOne()); }
public static void Send_Has_BlindCarbonCopies_But_Empty() { // Arrange var mailService = new MockMailService(); mailService.Recipients = new[] { "*****@*****.**" }; mailService.BlindCarbonCopies = new[] { string.Empty, "*****@*****.**" }; MailMessage message = new MailMessage(); // Act mailService.Send(message); // Assert Assert.Equal(1, message.To.Count); Assert.Equal(0, message.CC.Count); Assert.Equal(1, message.Bcc.Count); Assert.Equal("*****@*****.**", message.Bcc[0].Address); Assert.True(mailService.WaitHandle.WaitOne()); }
public static void Send_Has_CarbonCopies() { // Arrange var mailService = new MockMailService(); mailService.Recipients = new[] { "*****@*****.**" }; mailService.CarbonCopies = new[] { "*****@*****.**", "*****@*****.**" }; MailMessage message = new MailMessage(); // Act mailService.Send(message); // Assert Assert.Equal(1, message.To.Count); Assert.Equal(2, message.CC.Count); Assert.Equal("*****@*****.**", message.CC[0].Address); Assert.Equal("*****@*****.**", message.CC[1].Address); Assert.True(mailService.WaitHandle.WaitOne()); }