123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- 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<XingTangDbContext> 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<XingtangCall>();
- 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<XingtangCall>();
- 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<XingtangSatisfaction>();
- 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();
- }
- }
|