}
}
- [Fact]
- public async Task TestMailDeliveryAsync()
+ [Theory]
+ [InlineData("howdydoo")]
+ [InlineData("")]
+ [InlineData(null)]
+ public async Task TestMailDeliveryAsync(string body)
{
SmtpServer server = new SmtpServer();
SmtpClient client = new SmtpClient("localhost", server.EndPoint.Port);
- MailMessage msg = new MailMessage("foo@example.com", "bar@example.com", "hello", "howdydoo");
+ MailMessage msg = new MailMessage("foo@example.com", "bar@example.com", "hello", body);
string clientDomain = IPGlobalProperties.GetIPGlobalProperties().HostName.Trim().ToLower();
try
{
Thread t = new Thread(server.Run);
t.Start();
- await client.SendMailAsync(msg);
+ await client.SendMailAsync(msg).TimeoutAfter((int)TimeSpan.FromSeconds(30).TotalMilliseconds);
t.Join();
Assert.Equal("<foo@example.com>", server.MailFrom);
Assert.Equal("<bar@example.com>", server.MailTo);
Assert.Equal("hello", server.Subject);
- Assert.Equal("howdydoo", server.Body);
+ Assert.Equal(body ?? "", server.Body);
Assert.Equal(clientDomain, server.ClientDomain);
}
finally
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{A26D88B7-6EF6-4C8C-828B-7B57732CCE38}</ProjectGuid>
<Configurations>netstandard-Debug;netstandard-Release</Configurations>
<Compile Include="$(CommonTestPath)\System\IO\TempFile.cs">
<Link>Common\System\IO\TempFile.cs</Link>
</Compile>
+ <Compile Include="$(CommonTestPath)\System\Threading\Tasks\TaskTimeoutExtensions.cs">
+ <Link>Common\System\Threading\Tasks\TaskTimeoutExtensions.cs</Link>
+ </Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Net.NetworkInformation" />