using Hotline.Orders;
using Hotline.Settings;
using Hotline.Settings.TimeLimitDomain;
using Hotline.Share.Dtos.Settings;
using Hotline.Share.Enums.Settings;
using Shouldly;
using XF.Domain.Repository;

namespace Hotline.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 13:59:59", "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:00", "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, 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);
    }
}

