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 _repository; private readonly GuideTypeManager _manager; private readonly IDbContextProvider _dbContextProvider; private readonly IUnitOfWorkManager _unitOfWorkManager; public GuideTypeManagerTest() { _repository = Substitute.For>(); //_repository = GetRequiredService>(); _manager = GetRequiredService(); //_dbContextProvider = GetRequiredService>(); //_unitOfWorkManager = GetRequiredService(); } [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()); }); } } }