XingTangCallsSyncJobTest.cs 3.2 KB

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