using AutoFixture; using Hotline.Application.Jobs; using Hotline.Caching.Interfaces; using Hotline.Repository.SqlSugar; using Quartz; using SqlSugar; using XingTang.Sdk; namespace Hotline.Tests.Application; public class XingTangCallsSyncJobTest { private readonly XingTangCallsSyncJob xingTangCallsSyncJob; private readonly ISqlSugarClient _db; private readonly IFixture _fixture; private readonly XingTangCallSatisfactionSyncJob _xingTangCallSatisfactionSyncJob; private readonly ISystemSettingCacheManager _systemSettingCacheManager; public XingTangCallsSyncJobTest(XingTangCallsSyncJob xingTangCallsSyncJob, ISugarUnitOfWork uow, XingTangCallSatisfactionSyncJob xingTangCallSatisfactionSyncJob, ISystemSettingCacheManager systemSettingCacheManager) { this.xingTangCallsSyncJob = xingTangCallsSyncJob; _db = uow.Db; _fixture = new Fixture(); _xingTangCallSatisfactionSyncJob = xingTangCallSatisfactionSyncJob; _systemSettingCacheManager = systemSettingCacheManager; } [Fact] public async Task Handler_Test() { var unPushTime = _systemSettingCacheManager.CallSyncUnPushDateTime; var second = new Random().Next(0, 60); var inDto = _fixture.Create(); inDto.CallStartTime = DateTime.Parse("2024/11/19 18:07:" + second); inDto.IsSync = false; inDto.Tries = 0; inDto.CallGuid = DateTime.Now.ToString("yyyyMMddhhmmss") + "FLOW"; inDto.Ver = string.Empty; inDto.CustomerId = string.Empty; inDto.Id = new Random().Next(0, 100000); var inDto2 = _fixture.Create(); inDto2.CallStartTime = DateTime.Now; inDto2.CallGuid = DateTime.Now.ToString("yyyyMMddhhmmss") + "FLOW"; inDto2.IsSync = false; inDto2.Tries = 0; inDto2.Ver = string.Empty; inDto2.CustomerId = string.Empty; inDto2.Id = new Random().Next(0, 100000); await _db.Insertable(inDto).ExecuteCommandAsync(); await _db.Insertable(inDto2).ExecuteCommandAsync(); await xingTangCallsSyncJob.Execute(new JobContext()); var s1 = _fixture.Create(); s1.CallNo = inDto.CallGuid; s1.Result = new Random().Next(1, 5); s1.IsSync = false; s1.Tries = 0; await _db.Insertable(s1).ExecuteCommandAsync(); await _xingTangCallSatisfactionSyncJob.Execute(new JobContext()); } } public class JobContext : IJobExecutionContext { public IScheduler Scheduler => throw new NotImplementedException(); public ITrigger Trigger => throw new NotImplementedException(); public ICalendar? Calendar => throw new NotImplementedException(); public bool Recovering => throw new NotImplementedException(); public TriggerKey RecoveringTriggerKey => throw new NotImplementedException(); public int RefireCount => throw new NotImplementedException(); public JobDataMap MergedJobDataMap => throw new NotImplementedException(); public IJobDetail JobDetail => throw new NotImplementedException(); public IJob JobInstance => throw new NotImplementedException(); public DateTimeOffset FireTimeUtc => throw new NotImplementedException(); public DateTimeOffset? ScheduledFireTimeUtc => throw new NotImplementedException(); public DateTimeOffset? PreviousFireTimeUtc => throw new NotImplementedException(); public DateTimeOffset? NextFireTimeUtc => throw new NotImplementedException(); public string FireInstanceId => throw new NotImplementedException(); public object? Result { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public TimeSpan JobRunTime => throw new NotImplementedException(); public CancellationToken CancellationToken => CancellationToken.None; public object? Get(object key) { throw new NotImplementedException(); } public void Put(object key, object objectValue) { throw new NotImplementedException(); } }