mirror of https://github.com/abpframework/abp.git
4 changed files with 89 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.2</TargetFramework> |
|||
<LangVersion>latest</LangVersion> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.MailKit\Volo.Abp.MailKit.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,13 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.MailKit |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpMailKitModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpTestBaseModule))] |
|||
public class AbpMailKitTestModule :AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
using System.Net.Mail; |
|||
using System.Threading.Tasks; |
|||
using NSubstitute; |
|||
using Volo.Abp.BackgroundJobs; |
|||
using Volo.Abp.Emailing.Smtp; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.MailKit |
|||
{ |
|||
//Tests are commented because those tests can pass only when a true email configuration is set.
|
|||
public class MailKitSmtpEmailSender_Tests : AbpIntegratedTest<AbpMailKitTestModule> |
|||
{ |
|||
//[Fact]
|
|||
public async Task ShouldSendMailMessageAsync() |
|||
{ |
|||
var mailSender = CreateMailKitEmailSender(); |
|||
var mailMessage = new MailMessage("from_mail_address@asd.com", "to_mail_address@asd.com", "subject", "body") |
|||
{ IsBodyHtml = true }; |
|||
|
|||
await mailSender.SendAsync(mailMessage); |
|||
} |
|||
|
|||
//[Fact]
|
|||
public void ShouldSendMailMessage() |
|||
{ |
|||
var mailSender = CreateMailKitEmailSender(); |
|||
var mailMessage = new MailMessage("from_mail_address@asd.com", "to_mail_address@asd.com", "subject", "body") |
|||
{ IsBodyHtml = true }; |
|||
|
|||
mailSender.Send(mailMessage); |
|||
} |
|||
|
|||
private static MailKitSmtpEmailSender CreateMailKitEmailSender() |
|||
{ |
|||
var mailConfig = Substitute.For<ISmtpEmailSenderConfiguration>(); |
|||
var mailKitConfig = Substitute.For<IAbpMailKitConfiguration>(); |
|||
var bgJob = Substitute.For<IBackgroundJobManager>(); |
|||
|
|||
mailConfig.GetHostAsync().Returns("stmp_server_name"); |
|||
mailConfig.GetUserNameAsync().Returns("mail_server_user_name"); |
|||
mailConfig.GetPasswordAsync().Returns("mail_server_password"); |
|||
mailConfig.GetPortAsync().Returns(587); |
|||
mailConfig.GetEnableSslAsync().Returns(false); |
|||
|
|||
var mailSender = new MailKitSmtpEmailSender(mailConfig, bgJob, mailKitConfig); |
|||
return mailSender; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue