using Shentun.Peis.CustomerOrgGroupDetails; using Shentun.Peis.CustomerOrgGroups; using Shentun.Peis.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using Volo.Abp.Uow; using Xunit; using Xunit.Abstractions; namespace Shentun.Peis { public class CustomerOrgGroupDetailAppServiceTest : PeisApplicationTestBase { private readonly IRepository _repository; private readonly CustomerOrgGroupDetailAppService _appService; private readonly ITestOutputHelper _output; private readonly IUnitOfWorkManager _unitOfWorkManager; public CustomerOrgGroupDetailAppServiceTest(ITestOutputHelper testOutputHelper) { _output = testOutputHelper; _unitOfWorkManager = GetRequiredService(); _repository = GetRequiredService>(); _appService = GetRequiredService(); } [Fact] public async Task CreateCustomerOrgGroupDetailManyAsync() { using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin()) { var id = new Guid("3a0e6d96-4d37-af35-59cf-eb6f8d27c163"); var detailList = (await _repository.GetQueryableAsync()).Where(o => o.CustomerOrgGroupId == id).ToList(); CreateCustomerOrgGroupDetailDto dto = new CreateCustomerOrgGroupDetailDto() { CustomerOrgGroupId = id }; dto.details = new List(); foreach (var detail in detailList) { dto.details.Add(new CreateCustomerOrgGroupDetail_Detail() { CustomerOrgGroupId = id, AsbitemId = detail.AsbitemId, Price = detail.Price, Amount = detail.Amount }); } await _appService.CreateCustomerOrgGroupDetailManyAsync(dto); await unitOfWork.CompleteAsync(); } } } }