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.
		
		
		
		
		
			
		
			
				
					
					
						
							123 lines
						
					
					
						
							4.5 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							123 lines
						
					
					
						
							4.5 KiB
						
					
					
				
								using Shentun.WebPeis.Asbitems;
							 | 
						|
								using Shentun.WebPeis.Models;
							 | 
						|
								using Shentun.WebPeis.Persons;
							 | 
						|
								using Shentun.WebPeis.QuestionRegisters;
							 | 
						|
								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 class QuestionRegisterAppServiceTest<TStartupModule> : WebPeisApplicationTestBase<TStartupModule>
							 | 
						|
								    where TStartupModule : IAbpModule
							 | 
						|
								    {
							 | 
						|
								        private readonly IRepository<QuestionRegister> _repository;
							 | 
						|
								        private readonly QuestionRegisterAppService _appService;
							 | 
						|
								        private readonly ITestOutputHelper _output;
							 | 
						|
								        private readonly IUnitOfWorkManager _unitOfWorkManager;
							 | 
						|
								        public QuestionRegisterAppServiceTest(ITestOutputHelper output)
							 | 
						|
								        {
							 | 
						|
								            _unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
							 | 
						|
								            _repository = GetRequiredService<IRepository<QuestionRegister>>();
							 | 
						|
								            _appService = GetRequiredService<QuestionRegisterAppService>();
							 | 
						|
								            _output = output;
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        [Fact]
							 | 
						|
								        public async Task GetByPersonId()
							 | 
						|
								        {
							 | 
						|
								            using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
							 | 
						|
								            {
							 | 
						|
								
							 | 
						|
								                var entity = await _appService.GetByPersonIdAsync(new PersonIdInputDto()
							 | 
						|
								                {
							 | 
						|
								                    PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
							 | 
						|
								                });
							 | 
						|
								                foreach (var item in entity.QuestionRegisterItems)
							 | 
						|
								                {
							 | 
						|
								                    _output.WriteLine("-----------" + item.QuestionName + "-" + item.AnswerType );
							 | 
						|
								                    foreach (var answer in item.QuestionRegisterAnswers)
							 | 
						|
								                    {
							 | 
						|
								                        _output.WriteLine(answer.QuestionAnswerName + "-" + answer.ChildAnswerType  + answer.IsSelected);
							 | 
						|
								                        //answer.IsSelected = 'Y';
							 | 
						|
								                        foreach(var childAnswer in answer.Childs)
							 | 
						|
								                        {
							 | 
						|
								                            _output.WriteLine("----"+childAnswer.QuestionAnswerName  + childAnswer.IsSelected);
							 | 
						|
								                            //childAnswer.IsSelected = 'Y';
							 | 
						|
								                        }
							 | 
						|
								                    }
							 | 
						|
								                }
							 | 
						|
								                //var questionRegister = await _repository.FindAsync(o=>o.QuestionRegisterId ==  entity.QuestionRegisterId);
							 | 
						|
								                //if(questionRegister == null)
							 | 
						|
								                //{
							 | 
						|
								                //    await _appService.CreateAsync(entity);
							 | 
						|
								                //}
							 | 
						|
								                //else
							 | 
						|
								                //{
							 | 
						|
								                //    await _appService.UpdateAsync(entity);
							 | 
						|
								                //}
							 | 
						|
								               
							 | 
						|
								                await unitOfWork.CompleteAsync();
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        [Fact]
							 | 
						|
								        public async Task GetSubjectTypeListByPersonIdAsync()
							 | 
						|
								        {
							 | 
						|
								            using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
							 | 
						|
								            {
							 | 
						|
								
							 | 
						|
								                var entity = await _appService.GetSubjectTypeListByPersonIdAsync(new PersonIdInputDto()
							 | 
						|
								                {
							 | 
						|
								                    PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
							 | 
						|
								                });
							 | 
						|
								                foreach (var item in entity)
							 | 
						|
								                {
							 | 
						|
								                    _output.WriteLine("-----------" + item.QuestionSubjectTypeName );
							 | 
						|
								                    foreach (var answer in item.Answers)
							 | 
						|
								                    {
							 | 
						|
								                        _output.WriteLine(answer.QuestionAnswerName );
							 | 
						|
								                       
							 | 
						|
								                    }
							 | 
						|
								                  
							 | 
						|
								                }
							 | 
						|
								               
							 | 
						|
								
							 | 
						|
								                await unitOfWork.CompleteAsync();
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        [Fact]
							 | 
						|
								        public async Task GetQuestionRegisterListByPersonIdAsync()
							 | 
						|
								        {
							 | 
						|
								            using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
							 | 
						|
								            {
							 | 
						|
								
							 | 
						|
								                var entity = await _appService.GetQuestionRegisterListByPersonIdAsync(new PersonIdInputDto()
							 | 
						|
								                {
							 | 
						|
								                    PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
							 | 
						|
								                });
							 | 
						|
								                foreach (var item in entity)
							 | 
						|
								                {
							 | 
						|
								                    _output.WriteLine("-----------" + item.QuestionName);
							 | 
						|
								                    foreach (var answer in item.Answers)
							 | 
						|
								                    {
							 | 
						|
								                        _output.WriteLine(answer.Answer);
							 | 
						|
								
							 | 
						|
								                    }
							 | 
						|
								
							 | 
						|
								                }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								                await unitOfWork.CompleteAsync();
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								    }
							 | 
						|
								}
							 |