ZiGongExpireTimeTest.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using AngleSharp.Text;
  2. using Hotline.Orders;
  3. using Hotline.Settings;
  4. using Hotline.Settings.TimeLimitDomain;
  5. using Hotline.Settings.TimeLimitDomain.Repository;
  6. using Hotline.Share.Dtos.Settings;
  7. using Hotline.Share.Enums.FlowEngine;
  8. using Hotline.Share.Enums.Order;
  9. using Hotline.Share.Enums.Settings;
  10. using Hotline.Share.Tools;
  11. using Mapster;
  12. using Shouldly;
  13. using XF.Domain.Repository;
  14. namespace Hotline.Application.Tests.Domain;
  15. public class ZiGongExpireTimeTest
  16. {
  17. private readonly ZiGongExpireTimeLimit _ziGongExpireTimeLimit;
  18. private readonly IRepository<Order> _orderRepository;
  19. private readonly ITimeLimitSettingAttributeRepository _timeLimitSettingAttributeRepository;
  20. private readonly ITimeLimitSettingInventoryRepository _timeLimitSettingInventoryRepository;
  21. public ZiGongExpireTimeTest(ZiGongExpireTimeLimit ziGongExpireTimeLimit, IRepository<Order> orderRepository, ITimeLimitSettingAttributeRepository timeLimitSettingAttributeRepository, ITimeLimitSettingInventoryRepository timeLimitSettingInventoryRepository)
  22. {
  23. _ziGongExpireTimeLimit = ziGongExpireTimeLimit;
  24. _orderRepository = orderRepository;
  25. _timeLimitSettingAttributeRepository = timeLimitSettingAttributeRepository;
  26. _timeLimitSettingInventoryRepository = timeLimitSettingInventoryRepository;
  27. }
  28. [Theory]
  29. [InlineData("企业咨询件单元测试", false, "Enterprise","10","互联网", "2024-09-04 14:00:00", "CenterToOrg", "2024-09-05 14:00:00")]
  30. [InlineData("企业建议件单元测试", false, "Enterprise","15","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 14:00:00")]
  31. [InlineData("企业求助件单元测试", false, "Enterprise","20","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 14:00:00")]
  32. [InlineData("企业表扬件单元测试", false, "Enterprise","25","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 14:00:00")]
  33. [InlineData("企业举报件单元测试", false, "Enterprise","30","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 14:00:00")]
  34. [InlineData("企业投诉件单元测试", false, "Enterprise","35","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 14:00:00")]
  35. [InlineData("四川省12345咨询件单测试",false, "Citizen", "10","四川省12345", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-06 14:00:00")]
  36. [InlineData("四川省12345建议件单测试",false, "Citizen", "15","四川省12345", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-10 14:00:00")]
  37. [InlineData("中心到中心24小时", true, "Citizen", "10","四川省12345", "2024-09-12 14:00:00", "CenterToCenter", "2024-09-13 14:00:00")]
  38. public async Task CalcExpiredTime_Test(string title, bool is24, string identityType,string acceptTypeCode, string sourceChannel, string beginTxt, string flowTxt, string expected)
  39. {
  40. var beginTime = DateTime.Parse(beginTxt);
  41. Enum.TryParse(flowTxt, out EFlowDirection flow);
  42. var inDto = new OrderTimeClacInfo
  43. {
  44. IdentityType = identityType.ToEnum<EIdentityType>(),
  45. AcceptTypeCode = acceptTypeCode,
  46. SourceChannel = sourceChannel,
  47. FlowDirection = flow,
  48. Is24HoursComplete = is24
  49. };
  50. var time = await _ziGongExpireTimeLimit.CalcExpiredTime(beginTime, flow, inDto);
  51. time.ShouldNotBeNull();
  52. time.ExpiredTime.ShouldBe(DateTime.Parse(expected), $"{title} 期满时间错误 AcceptTypeCode:{acceptTypeCode}");
  53. }
  54. [Theory]
  55. [InlineData("", "Is24HoursComplete", "true", false)]
  56. [InlineData("", "HotspotSpliceName", "疫情", false)]
  57. [InlineData("10", "IdentityType", "Enterprise", false)]
  58. [InlineData("15", "IdentityType", "Enterprise", false)]
  59. [InlineData("20", "IdentityType", "Enterprise", false)]
  60. public async Task InitTimeLimitData_Test(string busCode, string name, string value, bool isCommon)
  61. {
  62. return;
  63. var attributeEntity = new TimeLimitSettingAttribute { BusCode = busCode, Name = name, Value = value, IsCommon = isCommon };
  64. var dataEntity = await _timeLimitSettingAttributeRepository.GetAsync(attributeEntity.BusCode, attributeEntity.Name, attributeEntity.Value);
  65. if (dataEntity is null) await _timeLimitSettingAttributeRepository.AddAsync(attributeEntity);
  66. }
  67. [Theory]
  68. [InlineData("", "Is24HoursComplete", "true", "Hour", 24, "24小时件")]
  69. [InlineData("", "HotspotSpliceName", "疫情", "WorkDay", 2, "疫情类2个工作日")]
  70. [InlineData("10", "IdentityType", "Enterprise", "WorkDay", 1, "企业 '咨询' 件1个工作日")]
  71. [InlineData("", "IdentityType", "Enterprise", "WorkDay", 2, "企业 '非咨询' 件2个工作日")]
  72. [InlineData("10", "SourceChannel", "四川省12345", "WorkDay", 1, "四川省12345 '咨询' 件1个工作日")]
  73. [InlineData("", "SourceChannel", "四川省12345", "WorkDay", 3, "四川省12345 '非咨询' 件3个工作日")]
  74. [InlineData("10", "SourceChannel", "省政民互动", "WorkDay", 1, "省政民互动 '咨询' 件1个工作日")]
  75. [InlineData("", "SourceChannel", "省政民互动", "WorkDay", 3, "省政民互动 '非咨询' 件3个工作日")]
  76. [InlineData("10", "SourceChannel", "国家政务平台", "WorkDay", 1, "国家政务平台 '咨询' 件1个工作日")]
  77. [InlineData("", "SourceChannel", "国家政务平台", "WorkDay", 3, "国家政务平台 '非咨询' 件3个工作日")]
  78. [InlineData("10", "SourceChannel", "天府通办", "WorkDay", 1, "天府通办 '咨询' 件1个工作日")]
  79. [InlineData("", "SourceChannel", "天府通办", "WorkDay", 3, "天府通办 '非咨询' 件3个工作日")]
  80. [InlineData("10", "SourceChannel", "中国政府网", "WorkDay", 1, "中国政府网 '咨询' 件1个工作日")]
  81. [InlineData("", "SourceChannel", "中国政府网", "WorkDay", 3, "中国政府网 '非咨询' 件3个工作日")]
  82. public async Task InitTimeLimitInventory_Test(string busCode, string name, string value, string timeType, int timeValue, string remark)
  83. {
  84. return;
  85. var attributeEntity = new TimeLimitSettingAttribute { BusCode = busCode, Name = name, Value = value, IsCommon = false };
  86. var dataEntity = await _timeLimitSettingAttributeRepository.GetAsync(attributeEntity.BusCode, attributeEntity.Name, attributeEntity.Value);
  87. if (dataEntity is null) await _timeLimitSettingAttributeRepository.AddAsync(attributeEntity);
  88. var attribute = await _timeLimitSettingAttributeRepository.GetAsync(busCode, name, value);
  89. attribute.ShouldNotBeNull($"{name} 属性未初始化");
  90. Enum.TryParse(timeType, out ETimeType eTimeType);
  91. var entity = new TimeLimitSettingInventory { Code = attribute.Code.ToString(), TimeType = eTimeType, TimeValue = timeValue, Percentage = 80, PercentageOne = 50 , Remark = remark};
  92. var m = await _timeLimitSettingInventoryRepository.GetByCode(entity.Code);
  93. if (m is null) await _timeLimitSettingInventoryRepository.AddAsync(entity);
  94. }
  95. }