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.
66 lines
2.2 KiB
66 lines
2.2 KiB
using NSubstitute;
|
|
using Shentun.Peis.EntityFrameworkCore;
|
|
using Shentun.Peis.GuidTypes;
|
|
using Shentun.Peis.ItemTypes;
|
|
using Shentun.Peis.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.EntityFrameworkCore;
|
|
using Volo.Abp.Uow;
|
|
using Xunit;
|
|
|
|
namespace Shentun.Peis
|
|
{
|
|
public class GuideTypeManagerTest : PeisDomainTestBase
|
|
{
|
|
private readonly IRepository<GuideType, Guid> _repository;
|
|
private readonly GuideTypeManager _manager;
|
|
private readonly IDbContextProvider<PeisDbContext> _dbContextProvider;
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
public GuideTypeManagerTest()
|
|
{
|
|
_repository = Substitute.For<IRepository<GuideType,Guid>>();
|
|
//_repository = GetRequiredService<IRepository<GuideType, Guid>>();
|
|
_manager = GetRequiredService<GuideTypeManager>();
|
|
//_dbContextProvider = GetRequiredService<IDbContextProvider<PeisDbContext>>();
|
|
//_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
|
|
}
|
|
[Fact]
|
|
public async Task Should_Set_CanAdd()
|
|
{
|
|
var createEntity = new GuideType();
|
|
createEntity.DisplayName = "normal";
|
|
var item = await _manager.CreateAsync(createEntity);
|
|
item = await _repository.InsertAsync(item,true);
|
|
if(item != null)
|
|
{
|
|
Console.WriteLine(item.Id.ToString());
|
|
}
|
|
|
|
}
|
|
[Fact]
|
|
public async Task Should_Set_CanAdd_Sync()
|
|
{
|
|
var createEntity = new GuideType();
|
|
createEntity.DisplayName = "normal";
|
|
var item = await _manager.CreateAsync(createEntity);
|
|
item = _repository.InsertAsync(item, true).Result;
|
|
Console.WriteLine(item.Id.ToString());
|
|
}
|
|
[Fact]
|
|
public async Task TestDataBase()
|
|
{
|
|
var db = await _dbContextProvider.GetDbContextAsync();
|
|
var items = db.Users.ToList();
|
|
items.ForEach(o =>
|
|
{
|
|
Console.WriteLine(o.Id.ToString());
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|