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.
78 lines
2.4 KiB
78 lines
2.4 KiB
using AutoMapper.Internal.Mappers;
|
|
using Microsoft.VisualBasic;
|
|
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;
|
|
using Xunit.Abstractions;
|
|
using Yitter.IdGenerator;
|
|
|
|
namespace Shentun.Sms.SmsApps
|
|
{
|
|
public class SmsAppManagerTest : SmsDomainTestBase
|
|
{
|
|
private readonly IRepository<SmsApp, Guid> _smsAppRepository;
|
|
private readonly SmsAppManager _smsAppManager;
|
|
private readonly IGuidGenerator _guidGenerator;
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
private readonly ITestOutputHelper _output;
|
|
|
|
public SmsAppManagerTest(
|
|
ITestOutputHelper output
|
|
)
|
|
{
|
|
_output = output;
|
|
_smsAppManager = GetRequiredService<SmsAppManager>();
|
|
_guidGenerator = GetRequiredService<IGuidGenerator>();
|
|
_smsAppRepository = GetRequiredService<IRepository<SmsApp, Guid>>();
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task CreateAsyncTest()
|
|
{
|
|
using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
var entity = new SmsApp(_guidGenerator.Create())
|
|
{
|
|
DisplayName = "测试数据",
|
|
IsThisSystem = 'N'
|
|
};
|
|
entity = await _smsAppManager.CreateAsync(entity);
|
|
await _smsAppRepository.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 _smsAppRepository.GetAsync(Id);
|
|
var newEntity = new SmsApp(_guidGenerator.Create())
|
|
{
|
|
DisplayName = "测试数据1",
|
|
IsThisSystem = 'N'
|
|
};
|
|
|
|
await _smsAppManager.UpdateAsync(newEntity, entity);
|
|
entity = await _smsAppRepository.UpdateAsync(entity);
|
|
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|