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.
		
		
		
		
		
			
		
			
				
					
					
						
							107 lines
						
					
					
						
							3.4 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							107 lines
						
					
					
						
							3.4 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.Security.Cryptography;
							 | 
						|
								using System.Text;
							 | 
						|
								using System.Threading.Tasks;
							 | 
						|
								using Volo.Abp;
							 | 
						|
								using Volo.Abp.Domain.Repositories;
							 | 
						|
								using Volo.Abp.Uow;
							 | 
						|
								using Volo.Abp.Linq;
							 | 
						|
								using Xunit;
							 | 
						|
								using Xunit.Abstractions;
							 | 
						|
								
							 | 
						|
								namespace Shentun.Peis
							 | 
						|
								{
							 | 
						|
								    public class GuideTypeManagerTest : PeisDomainTestBase
							 | 
						|
								    {
							 | 
						|
								        private readonly IRepository<GuideType, char> _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 GuideTypeManagerTest( ITestOutputHelper output)
							 | 
						|
								        {
							 | 
						|
								            _output = output;
							 | 
						|
								            //_dbContextProvider = GetRequiredService<IDbContextProvider<PeisDbContext>>();
							 | 
						|
								            //_dbContextProvider = dbContextProvider;
							 | 
						|
								            //_repository = Substitute.For<IRepository<GuideType,Guid>>();
							 | 
						|
								            _repository = GetRequiredService<IRepository<GuideType, char>>();
							 | 
						|
								            _itemTypeRepository = GetRequiredService<IRepository<ItemType, Guid>>();
							 | 
						|
								            _manager = GetRequiredService<GuideTypeManager>();
							 | 
						|
								
							 | 
						|
								            _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 GetListAsync()
							 | 
						|
								        {
							 | 
						|
								           
							 | 
						|
								            var items = await _repository.GetListAsync();
							 | 
						|
								            items.ForEach(o =>
							 | 
						|
								            {
							 | 
						|
								                _output.WriteLine(o.DisplayName.ToString());
							 | 
						|
								            });
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        [Fact]
							 | 
						|
								        [UnitOfWork]
							 | 
						|
								        public virtual async Task CheckAndDeleteAsync()
							 | 
						|
								        {
							 | 
						|
								            try
							 | 
						|
								            {
							 | 
						|
								                using (var uow = _unitOfWorkManager.Begin())
							 | 
						|
								                {
							 | 
						|
								                    var entity = await _repository.GetAsync('0');
							 | 
						|
								
							 | 
						|
								                    await _manager.CheckAndDeleteAsync(entity);
							 | 
						|
								                }
							 | 
						|
								            }
							 | 
						|
								            catch (Exception ex)
							 | 
						|
								            {
							 | 
						|
								                _output.WriteLine(ex.Message);
							 | 
						|
								            }
							 | 
						|
								           
							 | 
						|
								
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        [Fact]
							 | 
						|
								        public async Task TestDataBase()
							 | 
						|
								        {
							 | 
						|
								            //var db = await _dbContextProvider.GetDbContextAsync();
							 | 
						|
								            //var items = db.Users.ToList();
							 | 
						|
								            //items.ForEach(o =>
							 | 
						|
								            //{
							 | 
						|
								            //    Console.WriteLine(o.Id.ToString());
							 | 
						|
								            //});
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								}
							 |