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