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.

63 lines
2.3 KiB

2 years ago
  1. using Shentun.Peis.CustomerOrgGroupDetails;
  2. using Shentun.Peis.CustomerOrgGroups;
  3. using Shentun.Peis.Models;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Volo.Abp.Application.Services;
  10. using Volo.Abp.Domain.Repositories;
  11. using Volo.Abp.Uow;
  12. using Xunit;
  13. using Xunit.Abstractions;
  14. namespace Shentun.Peis
  15. {
  16. public class CustomerOrgGroupDetailAppServiceTest : PeisApplicationTestBase
  17. {
  18. private readonly IRepository<CustomerOrgGroupDetail> _repository;
  19. private readonly CustomerOrgGroupDetailAppService _appService;
  20. private readonly ITestOutputHelper _output;
  21. private readonly IUnitOfWorkManager _unitOfWorkManager;
  22. public CustomerOrgGroupDetailAppServiceTest(ITestOutputHelper testOutputHelper)
  23. {
  24. _output = testOutputHelper;
  25. _unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
  26. _repository = GetRequiredService<IRepository<CustomerOrgGroupDetail>>();
  27. _appService = GetRequiredService<CustomerOrgGroupDetailAppService>();
  28. }
  29. [Fact]
  30. public async Task CreateCustomerOrgGroupDetailManyAsync()
  31. {
  32. using (IUnitOfWork unitOfWork = _unitOfWorkManager.Begin())
  33. {
  34. var id = new Guid("3a0e6d96-4d37-af35-59cf-eb6f8d27c163");
  35. var detailList = (await _repository.GetQueryableAsync()).Where(o => o.CustomerOrgGroupId == id).ToList();
  36. CreateCustomerOrgGroupDetailDto dto = new CreateCustomerOrgGroupDetailDto()
  37. {
  38. CustomerOrgGroupId = id
  39. };
  40. dto.details = new List<CreateCustomerOrgGroupDetail_Detail>();
  41. foreach (var detail in detailList)
  42. {
  43. dto.details.Add(new CreateCustomerOrgGroupDetail_Detail()
  44. {
  45. CustomerOrgGroupId = id,
  46. AsbitemId = detail.AsbitemId,
  47. Price = detail.Price,
  48. Amount = detail.Amount
  49. });
  50. }
  51. await _appService.CreateCustomerOrgGroupDetailManyAsync(dto);
  52. await unitOfWork.CompleteAsync();
  53. }
  54. }
  55. }
  56. }