using Hotline.Api.Controllers;
using Hotline.Application.CallCenter;
using Hotline.Identity.Accounts;
using Hotline.Identity.Roles;
using Hotline.Share.Dtos.CallCenter;
using Hotline.Share.Enums.CallCenter;
using Hotline.Users;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using SqlSugar.Extensions;
using XF.Domain.Repository;

namespace Hotline.Application.Tests.Application;
public class DefaultCallApplicationTest
{
    private readonly XingTangCallApplication _defaultCallApplication;

    public DefaultCallApplicationTest(XingTangCallApplication defaultCallApplication)
    {
        _defaultCallApplication = defaultCallApplication;
    }

    [Fact]
    public async Task QueryCallsFixed_Test()
    {
        var inDto = new QueryCallsFixedDto();
        inDto.CallStartTimeEnd = DateTime.Now;
        inDto.CallStartTimeStart = "2024/10/01 00:00:00".ObjToDate();

        var items = await _defaultCallApplication.QueryCallsFixedAsync(inDto, new CancellationToken());
        items.ShouldNotBeNull();
    }

    [Fact]
    public async Task QueryCallsFixedThree_Test()
    {
        var inDto = new QueryCallsFixedDto();
        inDto.CallStartTimeEnd = DateTime.Now;
        inDto.CallStartTimeStart = "2024/11/08 00:00:00".ObjToDate();
        inDto.FromNo = "8205175";

        var items1 = await _defaultCallApplication.QueryCallsFixedAsync(inDto, new CancellationToken());
        items1.ShouldNotBeNull();
        foreach (var item in items1.Where(m => m.IsOrder))
        {
            item.Title.ShouldNotBeNull();
            item.OrderId.ShouldNotBeNull();
            item.OrderNo.ShouldNotBeNull();
        }

        inDto.ToNo = "13990006670";
        inDto.FromNo = null;
        inDto.Type = 2;
        var items = await _defaultCallApplication.QueryCallsFixedAsync(inDto, new CancellationToken());
        items.ShouldNotBeNull();
        items.Count().ShouldNotBe(0, "通过被叫号码查询失败");
        foreach (var item in items.Where(m => m.IsVisit))
        {
            item.Title.ShouldNotBeNull();
            item.OrderId.ShouldNotBeNull();
            item.OrderNo.ShouldNotBeNull();
        }
    }
}
