|
@@ -0,0 +1,43 @@
|
|
|
+using Hotline.Settings.TimeLimitDomain;
|
|
|
+using Hotline.Settings;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using XF.Domain.Repository;
|
|
|
+using Hotline.Orders;
|
|
|
+using Hotline.Share.Dtos.Settings;
|
|
|
+using Hotline.Share.Enums.Settings;
|
|
|
+using Shouldly;
|
|
|
+
|
|
|
+namespace Hotline.Application.Tests.Domain;
|
|
|
+public class LuZhouExpireTimeTest
|
|
|
+{
|
|
|
+ private readonly LuZhouExpireTimeLimit _calcExpireTime;
|
|
|
+ private readonly IRepository<Order> _orderRepository;
|
|
|
+ private readonly IRepository<TimeLimitSetting> _timeLimitSettingRepository;
|
|
|
+
|
|
|
+ public LuZhouExpireTimeTest(IRepository<TimeLimitSetting> timeLimitSettingRepository, IRepository<Order> orderRepository, LuZhouExpireTimeLimit calcExpireTime)
|
|
|
+ {
|
|
|
+ _timeLimitSettingRepository = timeLimitSettingRepository;
|
|
|
+ _orderRepository = orderRepository;
|
|
|
+ _calcExpireTime = calcExpireTime;
|
|
|
+ }
|
|
|
+
|
|
|
+ [Theory]
|
|
|
+ [InlineData("2024-09-04 14:00:00", 2, "10", "2024-09-06 14:00:00", "2024/9/6 10:24:00", "2024/9/5 14:00:00", "2个工作日")]
|
|
|
+ [InlineData("2024-09-04 14:01:01", 3, "10", "2024-09-09 14:01:01", "2024/9/6 17:37:01", "2024/9/6 9:31:01", "3个工作日")]
|
|
|
+ public async Task CalcEndTime_Test(string begin, int count, string busCode, string expiredTime, string nearlyExpiredTime, string nearlyExpiredTimeOne, string timeText)
|
|
|
+ {
|
|
|
+ var beginTime = DateTime.Parse(begin);
|
|
|
+ var result = await _calcExpireTime.CalcEndTime(beginTime, new TimeConfig(count, ETimeType.WorkDay), busCode);
|
|
|
+ result.ShouldNotBeNull();
|
|
|
+ result.ExpiredTime.ShouldBe(DateTime.Parse(expiredTime));
|
|
|
+ result.NearlyExpiredTime.ShouldBe(DateTime.Parse(nearlyExpiredTime));
|
|
|
+ result.NearlyExpiredTimeOne.ShouldBe(DateTime.Parse(nearlyExpiredTimeOne));
|
|
|
+ result.Count.ShouldBe(count);
|
|
|
+ result.TimeText.ShouldBe(timeText);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|