ZiGongExpireTimeTest.cs 6.9 KB

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