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.
130 lines
4.8 KiB
130 lines
4.8 KiB
using Microsoft.EntityFrameworkCore;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Shentun.Peis.GuidTypes;
|
|
using Shentun.Peis.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TencentCloud.Ame.V20190916.Models;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Uow;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Shentun.Peis
|
|
{
|
|
public class SysParmTypeManagerTest : PeisDomainTestBase
|
|
{
|
|
private readonly IRepository<SysParmType> _repository;
|
|
private readonly GuideTypeManager _manager;
|
|
//private readonly IDbContextProvider<PeisDbContext> _dbContextProvider;
|
|
private readonly ITestOutputHelper _output;
|
|
private readonly IRepository<ItemType, Guid> _itemTypeRepository;
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
public SysParmTypeManagerTest(ITestOutputHelper output)
|
|
{
|
|
_output = output;
|
|
_repository = GetRequiredService<IRepository<SysParmType>>();
|
|
_itemTypeRepository = GetRequiredService<IRepository<ItemType, Guid>>();
|
|
_manager = GetRequiredService<GuideTypeManager>();
|
|
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
|
|
}
|
|
[Fact]
|
|
public async Task GetListAsync()
|
|
{
|
|
var items = await _repository.GetListAsync();
|
|
items.ForEach(o =>
|
|
{
|
|
_output.WriteLine(o.Id + o.DisplayName.ToString());
|
|
});
|
|
|
|
}
|
|
[Fact]
|
|
public async Task GetByIdAsync()
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin())
|
|
{
|
|
//var queryableAsync = await _repository.GetQueryableAsync();
|
|
//var items = queryableAsync.Include(o => o.SysParms).ThenInclude(o => o.SysParmValues).
|
|
// Where(o => o.Id == "doctor_check_rule").ToList();
|
|
var item = await _repository.GetAsync(o => o.Id == "doctor_check_rule");
|
|
_output.WriteLine(item.Id + item.DisplayName);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetByIdNoUnitOfWork()
|
|
{
|
|
var item = await _repository.GetAsync(o => o.Id == "doctor_check_rule");
|
|
_output.WriteLine(item.Id + item.DisplayName);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetListByIdAsync()
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin())
|
|
{
|
|
//var queryableAsync = await _repository.GetQueryableAsync();
|
|
//var items = queryableAsync.Include(o => o.SysParms).ThenInclude(o => o.SysParmValues).
|
|
// Where(o => o.Id == "doctor_check_rule").ToList();
|
|
var items = _repository.GetQueryableAsync().GetAwaiter().GetResult().
|
|
Include(o => o.SysParms).ThenInclude(o => o.SysParmValues).
|
|
Where(o => o.Id == "doctor_check_rule").ToList();
|
|
items.ForEach(o =>
|
|
{
|
|
_output.WriteLine(o.Id + o.DisplayName.ToString());
|
|
foreach (var item in o.SysParms)
|
|
{
|
|
_output.WriteLine("SysParms " + item.Id + " " + item.DisplayName);
|
|
foreach (var item2 in item.SysParmValues)
|
|
{
|
|
_output.WriteLine("SysParmValues " + item2.OrganizationUnitId.ToString() + " " + item2.ParmValue);
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetListByIdNoUnitOfWorkAsync()
|
|
{
|
|
|
|
//var queryableAsync = await _repository.GetQueryableAsync();
|
|
//var items = queryableAsync.Include(o => o.SysParms).ThenInclude(o => o.SysParmValues).
|
|
// Where(o => o.Id == "doctor_check_rule").ToList();
|
|
try
|
|
{
|
|
var items = _repository.GetQueryableAsync().GetAwaiter().GetResult().
|
|
Include(o => o.SysParms).ThenInclude(o => o.SysParmValues).
|
|
Where(o => o.Id == "doctor_check_rule").ToList();
|
|
items.ForEach(o =>
|
|
{
|
|
_output.WriteLine(o.Id + o.DisplayName.ToString());
|
|
foreach (var item in o.SysParms)
|
|
{
|
|
_output.WriteLine("SysParms " + item.Id + " " + item.DisplayName);
|
|
foreach (var item2 in item.SysParmValues)
|
|
{
|
|
_output.WriteLine("SysParmValues " + item2.OrganizationUnitId.ToString() + " " + item2.ParmValue);
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_output.WriteLine(ex.Message);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|