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.

90 lines
3.0 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. using Shentun.WebPeis.Enums;
  2. using Shentun.WebPeis.Models;
  3. using Shentun.WebPeis.Persons;
  4. using Shentun.WebPeis.Wechats;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using Volo.Abp.Domain.Repositories;
  11. using Volo.Abp.Modularity;
  12. using Volo.Abp.Uow;
  13. using Xunit;
  14. using Xunit.Abstractions;
  15. namespace Shentun.WebPeis
  16. {
  17. public abstract class PersonAppServiceTest<TStartupModule> : WebPeisApplicationTestBase<TStartupModule>
  18. where TStartupModule : IAbpModule
  19. {
  20. private readonly IRepository<Person> _repository;
  21. private readonly PersonAppService _appService;
  22. private readonly ITestOutputHelper _output;
  23. private readonly IUnitOfWorkManager _unitOfWorkManager;
  24. public PersonAppServiceTest(ITestOutputHelper output)
  25. {
  26. //ITestOutputHelper testOutputHelper
  27. //_output = testOutputHelper;
  28. _unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
  29. _repository = GetRequiredService<IRepository<Person>>();
  30. _appService = GetRequiredService<PersonAppService>();
  31. _output = output;
  32. }
  33. [Fact]
  34. public async Task GetWechatUserTokenAsync()
  35. {
  36. using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
  37. {
  38. var entity = new WechatUserJsCodeInputDto()
  39. {
  40. JsCode = "0c1yTa0w3mErQ23eot3w3ocsxw4yTa0P"
  41. };
  42. var newEntity = await _appService.WeChatUserLoginAsync(entity);
  43. await unitOfWork.CompleteAsync();
  44. }
  45. }
  46. [Fact]
  47. public async Task CreateAsync()
  48. {
  49. using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
  50. {
  51. var entity = new CreatePersonDto()
  52. {
  53. JsCode = "0f1XjtHa1yzivH0rmsHa1FuJf32XjtHL",
  54. PersonName = "张三",
  55. MobileTelephone = "18911254911",
  56. MedicalCenterId = new Guid("150da355-dfbf-466b-9697-355836a862c4"),
  57. IdNo = "43062419790909931X",
  58. SexId = SexFlag.Male,
  59. WechatOpenId = "obZGv5RhSNxxpkDwT0Xaf9Fzn8NM",
  60. MaritalStatusId = MaritalStatusFlag.Married,
  61. };
  62. var newEntity = await _appService.CreateAsync(entity);
  63. await unitOfWork.CompleteAsync();
  64. }
  65. }
  66. [Fact]
  67. public async Task GetPersonKinshipList()
  68. {
  69. using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
  70. {
  71. var entityList = await _appService.GetPersonKinshipList();
  72. foreach (var entity in entityList)
  73. {
  74. _output.WriteLine(entity.PersonName);
  75. }
  76. await unitOfWork.CompleteAsync();
  77. }
  78. }
  79. }
  80. }