You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.9 KiB
115 lines
3.9 KiB
using Shentun.Sms.SmsTasks;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Guids;
|
|
using Volo.Abp.Uow;
|
|
using Xunit.Abstractions;
|
|
using Xunit;
|
|
|
|
namespace Shentun.Sms.SmsTasks
|
|
{
|
|
|
|
public class SmsTaskManagerTest : SmsDomainTestBase
|
|
{
|
|
private readonly IRepository<SmsTask, Guid> _smsTaskRepository;
|
|
private readonly SmsTaskManager _smsTaskManager;
|
|
private readonly IGuidGenerator _guidGenerator;
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
private readonly ITestOutputHelper _output;
|
|
|
|
public SmsTaskManagerTest(
|
|
ITestOutputHelper output
|
|
)
|
|
{
|
|
_output = output;
|
|
_smsTaskManager = GetRequiredService<SmsTaskManager>();
|
|
_guidGenerator = GetRequiredService<IGuidGenerator>();
|
|
_smsTaskRepository = GetRequiredService<IRepository<SmsTask, Guid>>();
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task CreateAsyncTest()
|
|
{
|
|
using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
var entity = new SmsTask(_guidGenerator.Create())
|
|
{
|
|
Content = "这是一个短信内容",
|
|
IsActive = 'Y',
|
|
MobileTelephone = "13787791681",
|
|
CountryCode = "86",
|
|
PersonId = Guid.NewGuid().ToString(),
|
|
PersonName = "文先德",
|
|
SmsAppId = Guid.Parse("3a11921f-5caa-a313-8d61-dae87d1f2185"),
|
|
SmsTypeId = Guid.Parse("3a119222-2219-ba1a-d411-ecf96ab3f0de"),
|
|
StopTime = DateTime.Now.AddDays(15),
|
|
TaskCycleType = '1',
|
|
TaskCorn = "0 0 * * * ?",
|
|
SenderId = "",
|
|
SenderName = "",
|
|
ThirdId = ""
|
|
};
|
|
entity = await _smsTaskManager.CreateAsync(entity);
|
|
await _smsTaskRepository.InsertAsync(entity);
|
|
|
|
await unitOfWork.CompleteAsync();
|
|
|
|
_output.WriteLine(entity.Id.ToString());
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task UpdateAsyncTest()
|
|
{
|
|
using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
var Id = Guid.Parse("3a118c1d-b8d2-898a-b135-d75f50135e62");
|
|
|
|
var entity = await _smsTaskRepository.GetAsync(Id);
|
|
var newEntity = new SmsTask(_guidGenerator.Create())
|
|
{
|
|
Content = entity.Content,
|
|
IsActive = entity.IsActive,
|
|
MobileTelephone = entity.MobileTelephone,
|
|
CountryCode = entity.CountryCode,
|
|
PersonId = entity.PersonId,
|
|
PersonName = entity.PersonName,
|
|
SmsAppId = entity.SmsAppId,
|
|
SmsTypeId = entity.SmsTypeId,
|
|
StopTime = entity.StopTime,
|
|
TaskCycleType = entity.TaskCycleType,
|
|
TaskCorn = entity.TaskCorn,
|
|
SenderId = entity.SenderId,
|
|
SenderName = entity.SenderName,
|
|
ThirdId = entity.ThirdId
|
|
};
|
|
|
|
await _smsTaskManager.UpdateAsync(newEntity, entity);
|
|
|
|
await _smsTaskRepository.UpdateAsync(entity);
|
|
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public async Task DeleteAsyncTest()
|
|
{
|
|
using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
var Id = Guid.Parse("3a118c1d-b8d2-898a-b135-d75f50135e62");
|
|
|
|
await _smsTaskManager.CheckIsDeleteAsync(Id);
|
|
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|