XingTangCallsSyncJobTest.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using AutoFixture;
  2. using Hotline.Application.Jobs;
  3. using Hotline.Repository.SqlSugar;
  4. using Quartz;
  5. using SqlSugar;
  6. using XingTang.Sdk;
  7. namespace Hotline.Tests.Application;
  8. public class XingTangCallsSyncJobTest
  9. {
  10. private readonly XingTangCallsSyncJob xingTangCallsSyncJob;
  11. private readonly ISqlSugarClient _db;
  12. private readonly IFixture _fixture;
  13. public XingTangCallsSyncJobTest(XingTangCallsSyncJob xingTangCallsSyncJob, ISugarUnitOfWork<XingTangDbContext> uow)
  14. {
  15. this.xingTangCallsSyncJob = xingTangCallsSyncJob;
  16. _db = uow.Db;
  17. _fixture = new Fixture();
  18. }
  19. [Fact]
  20. public async Task Handler_Test()
  21. {
  22. var second = new Random().Next(0, 60);
  23. var inDto = _fixture.Create<XingtangCall>();
  24. inDto.CallStartTime = DateTime.Parse("2024/11/19 18:07:" + second);
  25. inDto.IsSync = false;
  26. inDto.Tries = 0;
  27. inDto.CallGuid = DateTime.Now.ToString("yyyyMMddhhmmss") + "FLOW";
  28. inDto.Ver = string.Empty;
  29. inDto.Id = new Random().Next(0, 100000);
  30. var inDto2 = _fixture.Create<XingtangCall>();
  31. inDto2.CallStartTime = DateTime.Now;
  32. inDto2.CallGuid = DateTime.Now.ToString("yyyyMMddhhmmss") + "FLOW";
  33. inDto2.IsSync = false;
  34. inDto2.Tries = 0;
  35. inDto2.Ver = string.Empty;
  36. inDto2.Id = new Random().Next(0, 100000);
  37. await _db.Insertable(inDto).ExecuteCommandAsync();
  38. await _db.Insertable(inDto2).ExecuteCommandAsync();
  39. await xingTangCallsSyncJob.Execute(new JobContext());
  40. }
  41. }
  42. public class JobContext : IJobExecutionContext
  43. {
  44. public IScheduler Scheduler => throw new NotImplementedException();
  45. public ITrigger Trigger => throw new NotImplementedException();
  46. public ICalendar? Calendar => throw new NotImplementedException();
  47. public bool Recovering => throw new NotImplementedException();
  48. public TriggerKey RecoveringTriggerKey => throw new NotImplementedException();
  49. public int RefireCount => throw new NotImplementedException();
  50. public JobDataMap MergedJobDataMap => throw new NotImplementedException();
  51. public IJobDetail JobDetail => throw new NotImplementedException();
  52. public IJob JobInstance => throw new NotImplementedException();
  53. public DateTimeOffset FireTimeUtc => throw new NotImplementedException();
  54. public DateTimeOffset? ScheduledFireTimeUtc => throw new NotImplementedException();
  55. public DateTimeOffset? PreviousFireTimeUtc => throw new NotImplementedException();
  56. public DateTimeOffset? NextFireTimeUtc => throw new NotImplementedException();
  57. public string FireInstanceId => throw new NotImplementedException();
  58. public object? Result { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  59. public TimeSpan JobRunTime => throw new NotImplementedException();
  60. public CancellationToken CancellationToken => CancellationToken.None;
  61. public object? Get(object key)
  62. {
  63. throw new NotImplementedException();
  64. }
  65. public void Put(object key, object objectValue)
  66. {
  67. throw new NotImplementedException();
  68. }
  69. }