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 _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(); _guidGenerator = GetRequiredService(); _smsAppRepository = GetRequiredService>(); _unitOfWorkManager = GetRequiredService(); } [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(); } } } }