12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using AutoFixture;
- using Hotline.Application.Jobs;
- 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;
- public XingTangCallsSyncJobTest(XingTangCallsSyncJob xingTangCallsSyncJob, ISugarUnitOfWork<XingTangDbContext> uow)
- {
- this.xingTangCallsSyncJob = xingTangCallsSyncJob;
- _db = uow.Db;
- _fixture = new Fixture();
- }
- [Fact]
- public async Task Handler_Test()
- {
- 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.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.Id = new Random().Next(0, 100000);
- await _db.Insertable(inDto).ExecuteCommandAsync();
- await _db.Insertable(inDto2).ExecuteCommandAsync();
- await xingTangCallsSyncJob.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();
- }
- }
|