using Shentun.Sms.SmsApps; 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.SmsInterfaces { public class SmsInterfaceManagerTest : SmsDomainTestBase { private readonly IRepository _smsInterfaceRepository; private readonly SmsInterfaceManager _smsInterfaceManager; private readonly IGuidGenerator _guidGenerator; private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly ITestOutputHelper _output; public SmsInterfaceManagerTest( ITestOutputHelper output ) { _output = output; _smsInterfaceManager = GetRequiredService(); _guidGenerator = GetRequiredService(); _smsInterfaceRepository = GetRequiredService>(); _unitOfWorkManager = GetRequiredService(); } [Fact] public async Task CreateAsyncTest() { using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin()) { var entity = new SmsInterface("010") { DisplayName = "测试数据", OrgName = "测试发送单位名称" }; entity = await _smsInterfaceManager.CreateAsync(entity); await _smsInterfaceRepository.InsertAsync(entity); await unitOfWork.CompleteAsync(); _output.WriteLine(entity.Id.ToString()); } } [Fact] public async Task UpdateAsyncTest() { using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin()) { var Id = "010"; var entity = await _smsInterfaceRepository.GetAsync(Id); var newEntity = new SmsInterface("010") { DisplayName = "测试数据2", OrgName = "测试发送单位名称2" }; await _smsInterfaceManager.UpdateAsync(newEntity, entity); await _smsInterfaceRepository.UpdateAsync(entity); await unitOfWork.CompleteAsync(); } } [Fact] public async Task DeleteAsyncTest() { using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin()) { var Id = "010"; await _smsInterfaceManager.CheckIsDeleteAsync(Id); await unitOfWork.CompleteAsync(); } } } }