Skip to content

Commit 02bd907

Browse files
committed
Reduce execution time of RecurringJobSchedulerFacts
1 parent fb35d3f commit 02bd907

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: tests/Hangfire.Core.Tests/Server/RecurringJobSchedulerFacts.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RecurringJobSchedulerFacts
3131
private readonly BackgroundJobMock _backgroundJobMock;
3232

3333
private static readonly string _expressionString = "* * * * *";
34-
private static readonly TimeSpan _delay = TimeSpan.FromMilliseconds(100);
34+
private static readonly TimeSpan _delay = TimeSpan.FromMilliseconds(1);
3535
private readonly CronExpression _cronExpression = CronExpression.Parse(_expressionString);
3636
private readonly DateTime _nowInstant = new DateTime(2017, 03, 30, 15, 30, 0, DateTimeKind.Utc);
3737
private readonly DateTime _nextInstant;
@@ -716,7 +716,7 @@ public void Execute_TriggersRecurringJobOnce_WithMissedScheduleByDefault(bool ba
716716
_recurringJob["Cron"] = "0 * * * *";
717717
_recurringJob["LastExecution"] = JobHelper.SerializeDateTime(_nowInstant.AddDays(-1));
718718

719-
var scheduler = CreateScheduler();
719+
var scheduler = CreateScheduler(delay: TimeSpan.FromMilliseconds(100));
720720

721721
// Act
722722
scheduler.Execute(_context.Object);
@@ -747,7 +747,7 @@ public void Execute_TriggersRecurringJobMultipleTimes_WithMissedScheduleWhenStri
747747
_recurringJob["LastExecution"] = JobHelper.SerializeDateTime(_nowInstant.AddHours(-3));
748748
_recurringJob["Misfire"] = MisfireHandlingMode.Strict.ToString("D");
749749

750-
var scheduler = CreateScheduler();
750+
var scheduler = CreateScheduler(delay: TimeSpan.FromMilliseconds(100));
751751

752752
// Act
753753
scheduler.Execute(_context.Object);
@@ -786,7 +786,7 @@ public void Execute_DoesNotTriggerRecurringJob_WithMissedScheduleWhenIgnorableMo
786786
_recurringJob["LastExecution"] = JobHelper.SerializeDateTime(_nowInstant.AddHours(-3));
787787
_recurringJob["Misfire"] = MisfireHandlingMode.Ignorable.ToString("D");
788788

789-
var scheduler = CreateScheduler();
789+
var scheduler = CreateScheduler(delay: TimeSpan.FromMilliseconds(100));
790790

791791
// Act
792792
scheduler.Execute(_context.Object);
@@ -816,7 +816,7 @@ public void Execute_TriggersRecurringJob_WhenIgnorableModeIsUsed_AndErrorIsSligh
816816
_recurringJob["LastExecution"] = JobHelper.SerializeDateTime(_nowInstant.AddHours(-3));
817817
_recurringJob["Misfire"] = MisfireHandlingMode.Ignorable.ToString("D");
818818

819-
var scheduler = CreateScheduler();
819+
var scheduler = CreateScheduler(delay: TimeSpan.FromMilliseconds(100));
820820

821821
// Act
822822
scheduler.Execute(_context.Object);
@@ -847,7 +847,7 @@ public void Execute_DoesNotMissCurrentExecution_ForAnyMisfireHandlingMode(bool b
847847
_recurringJob["LastExecution"] = JobHelper.SerializeDateTime(_nowInstant.AddHours(-3));
848848
_recurringJob["Misfire"] = mode.ToString("D");
849849

850-
var scheduler = CreateScheduler();
850+
var scheduler = CreateScheduler(delay: TimeSpan.FromMilliseconds(100));
851851

852852
// Act
853853
scheduler.Execute(_context.Object);
@@ -1310,11 +1310,11 @@ private void EnableBatching()
13101310
.Throws(new ArgumentNullException("key"));
13111311
}
13121312

1313-
private RecurringJobScheduler CreateScheduler(DateTime? lastExecution = null)
1313+
private RecurringJobScheduler CreateScheduler(DateTime? lastExecution = null, TimeSpan? delay = null)
13141314
{
13151315
var scheduler = new RecurringJobScheduler(
13161316
_factory.Object,
1317-
_delay,
1317+
delay ?? _delay,
13181318
_timeZoneResolver.Object,
13191319
_nowInstantFactory);
13201320

0 commit comments

Comments
 (0)