Skip to content

Commit

Permalink
added userState to SendAsync extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
smsohan committed Mar 7, 2011
1 parent 257c48a commit fe91083
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Mvc.Mailer.Test/ExtensionMethods/MailMessageExtensionsTest.cs
Expand Up @@ -7,6 +7,7 @@
using System.Net.Mail;
using System.IO;
using System.Threading;
using Moq;

namespace Mvc.Mailer.Test
{
Expand Down Expand Up @@ -45,11 +46,20 @@ public void TestSend()
[Test]
public void TestSendAsync()
{
_mailMessage.SendAsync(_smtpClient);
_mailMessage.SendAsync(smtpClient: _smtpClient);
Assert.Pass("Mail Send Async working since no exception wast thrown");

}

[Test]
public void SendAsync_with_userState_should_pass_that()
{
var client = new Mock<ISmtpClient>();
client.Setup(c => c.SendAsync(_mailMessage, "something"));
_mailMessage.SendAsync(userState: "something", smtpClient: client.Object);
client.VerifyAll();
}

[Test]
public void In_Test_Mode_should_use_TestSmtpClient()
{
Expand Down
4 changes: 2 additions & 2 deletions Mvc.Mailer/ExtensionMethods/MailMessageExtensions.cs
Expand Up @@ -36,11 +36,11 @@ public static void Send(this MailMessage message, ISmtpClient smtpClient = null)
/// Asynchronously Sends a MailMessage using smtpClient
/// </summary>
/// <param name="message">The mailMessage Object</param>
/// <param name="userState">The userState</param>
/// <param name="smtpClient">leave null to use default System.Net.Mail.SmtpClient</param>
public static void SendAsync(this MailMessage message, ISmtpClient smtpClient = null)
public static void SendAsync(this MailMessage message, object userState = null, ISmtpClient smtpClient = null)
{
smtpClient = smtpClient ?? GetSmtpClient();
var userState = "userState";
smtpClient.SendAsync(message, userState);
}

Expand Down

0 comments on commit fe91083

Please sign in to comment.