diff --git a/src/LinkDotNet.NCronJob/InternalsVisibleTo.cs b/src/LinkDotNet.NCronJob/InternalsVisibleTo.cs new file mode 100644 index 0000000..f881217 --- /dev/null +++ b/src/LinkDotNet.NCronJob/InternalsVisibleTo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("NCronJob.Tests")] diff --git a/src/LinkDotNet.NCronJob/Scheduler/CronScheduler.cs b/src/LinkDotNet.NCronJob/Scheduler/CronScheduler.cs index c7fc5ee..778f467 100644 --- a/src/LinkDotNet.NCronJob/Scheduler/CronScheduler.cs +++ b/src/LinkDotNet.NCronJob/Scheduler/CronScheduler.cs @@ -63,12 +63,9 @@ private Dictionary<DateTime, List<Run>> GetJobRuns() foreach (var cron in registry.GetAllCronJobs()) { - var utcNow = DateTime.UtcNow; + var utcNow = timeProvider.GetUtcNow().DateTime; var runDates = cron.CrontabSchedule.GetNextOccurrences(utcNow, utcNow.AddMinutes(1)); - if (runDates is not null) - { - AddJobRuns(runMap, runDates, cron); - } + AddJobRuns(runMap, runDates, cron); } return runMap; @@ -95,7 +92,7 @@ private static void AddJobRuns( private DateTime UtcNowMinutePrecision() { - var now = timeProvider.GetUtcNow(); + var now = timeProvider.GetUtcNow().DateTime; return new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0, DateTimeKind.Utc); }