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.
 
 
 

90 lines
3.0 KiB

using Shentun.WebPeis.Enums;
using Shentun.WebPeis.Models;
using Shentun.WebPeis.Persons;
using Shentun.WebPeis.Wechats;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Xunit;
using Xunit.Abstractions;
namespace Shentun.WebPeis
{
public abstract class PersonAppServiceTest<TStartupModule> : WebPeisApplicationTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IRepository<Person> _repository;
private readonly PersonAppService _appService;
private readonly ITestOutputHelper _output;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public PersonAppServiceTest(ITestOutputHelper output)
{
//ITestOutputHelper testOutputHelper
//_output = testOutputHelper;
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_repository = GetRequiredService<IRepository<Person>>();
_appService = GetRequiredService<PersonAppService>();
_output = output;
}
[Fact]
public async Task GetWechatUserTokenAsync()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = new WechatUserJsCodeInputDto()
{
JsCode = "0c1yTa0w3mErQ23eot3w3ocsxw4yTa0P"
};
var newEntity = await _appService.WeChatUserLoginAsync(entity);
await unitOfWork.CompleteAsync();
}
}
[Fact]
public async Task CreateAsync()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = new CreatePersonDto()
{
JsCode = "0f1XjtHa1yzivH0rmsHa1FuJf32XjtHL",
PersonName = "张三",
MobileTelephone = "18911254911",
MedicalCenterId = new Guid("150da355-dfbf-466b-9697-355836a862c4"),
IdNo = "43062419790909931X",
SexId = SexFlag.Male,
WechatOpenId = "obZGv5RhSNxxpkDwT0Xaf9Fzn8NM",
MaritalStatusId = MaritalStatusFlag.Married,
};
var newEntity = await _appService.CreateAsync(entity);
await unitOfWork.CompleteAsync();
}
}
[Fact]
public async Task GetPersonKinshipList()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entityList = await _appService.GetPersonKinshipList();
foreach (var entity in entityList)
{
_output.WriteLine(entity.PersonName);
}
await unitOfWork.CompleteAsync();
}
}
}
}