mirror of https://github.com/abpframework/abp.git
10 changed files with 119 additions and 8 deletions
@ -0,0 +1,3 @@ |
|||
{ |
|||
"role": "lib.test" |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.test.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Sms.TencentCloud\Volo.Abp.Sms.TencentCloud.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Sms\Volo.Abp.Sms.csproj" /> |
|||
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
|||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" /> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="appsettings.json" /> |
|||
<Content Include="appsettings.json"> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.Testing; |
|||
|
|||
namespace Volo.Abp.Sms.TencentCloud; |
|||
|
|||
public class AbpSmsTencentCloudTestBase : AbpIntegratedTest<AbpSmsTencentCloudTestsModule> |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
{ |
|||
options.UseAutofac(); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Sms.TencentCloud; |
|||
|
|||
[DependsOn(typeof(AbpSmsTencentCloudModule))] |
|||
public class AbpSmsTencentCloudTestsModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
Configure<AbpTencentCloudSmsOptions>( |
|||
configuration.GetSection("AbpTencentCloudSms") |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.Sms.TencentCloud; |
|||
|
|||
public class TencentCloudSmsSenderTests : AbpSmsTencentCloudTestBase |
|||
{ |
|||
private readonly ISmsSender _smsSender; |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public TencentCloudSmsSenderTests() |
|||
{ |
|||
_configuration = GetRequiredService<IConfiguration>(); |
|||
_smsSender = GetRequiredService<ISmsSender>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task SendSms_Test() |
|||
{ |
|||
var config = _configuration.GetSection("AbpTencentCloudSms"); |
|||
|
|||
// Please fill in the real parameters in the appsettings.json file.
|
|||
if (config["SecretId"] == "<Enter your SecretId from TencentCloud>") |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var msg = new SmsMessage(config["TargetPhoneNumber"], |
|||
config["TemplateParam"]); |
|||
msg.Properties.Add(TencentCloudSmsProperties.SignName, config["SignName"]); |
|||
msg.Properties.Add(TencentCloudSmsProperties.TemplateId, config["TemplateId"]); |
|||
|
|||
await _smsSender.SendAsync(msg); |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
{ |
|||
"AbpTencentCloudSms": { |
|||
"SecretId": "<Enter your SecretId from TencentCloud>", |
|||
"SecretKey": "<Enter your SecretKey from TencentCloud>", |
|||
"Region": "<Enter your Region from TencentCloud>", |
|||
"SmsSdkAppId": "<Enter your SmsSdkAppId from TencentCloud>", |
|||
"Endpoint": "<Enter your EndPoint from TencentCloud>", |
|||
"TargetPhoneNumber": "<Enter the target phone number to receive the SMS>", |
|||
"SignName": "<Enter the SignName from TencentCloud>", |
|||
"TemplateId": "<Enter the TemplateId you need to send>", |
|||
"TemplateParam": "<Enter the template parameters,split by ','>" |
|||
} |
|||
} |
|||
Loading…
Reference in new issue