Skip to content

Commit

Permalink
QRTZNET-217: Triggers fail to obey millisecond precision when setting…
Browse files Browse the repository at this point in the history
… start time
  • Loading branch information
lahma committed Aug 22, 2010
1 parent c6cead6 commit 5cdcca4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Quartz.Tests.Unit/CronTriggerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,14 @@ public void BasicCronTriggerTest()

Assert.IsNull(trigger.ComputeFirstFireTimeUtc(null));
}

[Test]
public void TestPrecision()
{
Trigger trigger = new CronTrigger();
trigger.StartTimeUtc = new DateTime(1982, 6, 28, 13, 5, 5, 233);
Assert.IsFalse(trigger.HasMillisecondPrecision);
Assert.AreEqual(0, trigger.StartTimeUtc.Millisecond);
}
}
}
9 changes: 9 additions & 0 deletions src/Quartz.Tests.Unit/NthIncludedDayTriggerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,14 @@ protected override void VerifyMatch(object target, object deserialized)
Assert.AreEqual(targetTrigger.NextFireCutoffInterval, deserializedTrigger.NextFireCutoffInterval);
// Assert.AreEqual(TimeZone.getDefault(), deserializedTrigger.getTimeZone());
}

[Test]
public void TestPrecision()
{
Trigger trigger = new NthIncludedDayTrigger();
trigger.StartTimeUtc = new DateTime(1982, 6, 28, 13, 5, 5, 233);
Assert.IsFalse(trigger.HasMillisecondPrecision);
Assert.AreEqual(0, trigger.StartTimeUtc.Millisecond);
}
}
}
11 changes: 10 additions & 1 deletion src/Quartz.Tests.Unit/SimpleTriggerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ public void TestGetFireTimeAfter_WithCalendar()
DateTime? fireTimeAfter = simpleTrigger.GetNextFireTimeUtc();

Assert.IsNull(fireTimeAfter);
}
}

[Test]
public void TestPrecision()
{
Trigger trigger = new SimpleTrigger();
trigger.StartTimeUtc = new DateTime(1982, 6, 28, 13, 5, 5, 233);
Assert.IsTrue(trigger.HasMillisecondPrecision);
Assert.AreEqual(233, trigger.StartTimeUtc.Millisecond);
}
}
}
2 changes: 1 addition & 1 deletion src/Quartz/Trigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public virtual DateTime StartTimeUtc
throw new ArgumentException("End time cannot be before start time");
}

if (HasMillisecondPrecision)
if (!HasMillisecondPrecision)
{
// round off millisecond...
startTimeUtc = new DateTime(value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second);
Expand Down

0 comments on commit 5cdcca4

Please sign in to comment.