Skip to content

Commit

Permalink
Problem validating new misfire instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed May 16, 2011
1 parent 47332ca commit bbf3c26
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Quartz.Tests.Unit/CalendarIntervalTriggerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,38 @@ public void TestFinalFireTimes()
Assert.IsTrue((endCalendar.Equals(testTime)), "Final fire time not computed correctly for minutely interval.");
}

[Test]
public void TestMisfireInstructionValidity()
{
CalendarIntervalTriggerImpl trigger = new CalendarIntervalTriggerImpl();

try
{
trigger.MisfireInstruction = MisfireInstruction.IgnoreMisfirePolicy;
trigger.MisfireInstruction = MisfireInstruction.SmartPolicy;
trigger.MisfireInstruction = MisfireInstruction.CalendarIntervalTrigger.DoNothing;
trigger.MisfireInstruction = MisfireInstruction.CalendarIntervalTrigger.FireOnceNow;
}
catch (Exception)
{
Assert.Fail("Unexpected exception while setting misfire instruction.");
}

try
{
trigger.MisfireInstruction = MisfireInstruction.CalendarIntervalTrigger.DoNothing + 1;

Assert.Fail("Expected exception while setting invalid misfire instruction but did not get it.");
}
catch (Exception ex)
{
if (ex is AssertionException)
{
throw;
}
}
}

protected override object GetTargetObject()
{
JobDataMap jobDataMap = new JobDataMap();
Expand Down
33 changes: 33 additions & 0 deletions src/Quartz.Tests.Unit/CronTriggerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,38 @@ public void TestQuartz558()

Assert.AreEqual(trigger, trigger2, "Cloning failed");
}

[Test]
public void TestMisfireInstructionValidity()
{
CronTriggerImpl trigger = new CronTriggerImpl();

try
{
trigger.MisfireInstruction = MisfireInstruction.IgnoreMisfirePolicy;
trigger.MisfireInstruction = MisfireInstruction.SmartPolicy;
trigger.MisfireInstruction = MisfireInstruction.CronTrigger.DoNothing;
trigger.MisfireInstruction = MisfireInstruction.CronTrigger.FireOnceNow;
}
catch (Exception)
{
Assert.Fail("Unexpected exception while setting misfire instruction.");
}

try
{
trigger.MisfireInstruction = MisfireInstruction.CronTrigger.DoNothing + 1;

Assert.Fail("Expected exception while setting invalid misfire instruction but did not get it.");
}
catch (Exception ex)
{
if (ex is AssertionException)
{
throw;
}
}
}

}
}
36 changes: 36 additions & 0 deletions src/Quartz.Tests.Unit/SimpleTriggerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,41 @@ public void TestPrecision()
Assert.IsTrue(trigger.HasMillisecondPrecision);
Assert.AreEqual(233, trigger.StartTimeUtc.Millisecond);
}

[Test]
public void TestMisfireInstructionValidity()
{
SimpleTriggerImpl trigger = new SimpleTriggerImpl();

try
{
trigger.MisfireInstruction = MisfireInstruction.IgnoreMisfirePolicy;
trigger.MisfireInstruction = MisfireInstruction.SmartPolicy;
trigger.MisfireInstruction = MisfireInstruction.SimpleTrigger.FireNow;
trigger.MisfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNextWithExistingCount;
trigger.MisfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNextWithRemainingCount;
trigger.MisfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNowWithExistingRepeatCount;
trigger.MisfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNowWithRemainingRepeatCount;
}
catch (Exception)
{
Assert.Fail("Unexpected exception while setting misfire instruction.");
}

try
{
trigger.MisfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNextWithExistingCount + 1;

Assert.Fail("Expected exception while setting invalid misfire instruction but did not get it.");
}
catch (Exception ex)
{
if (ex is AssertionException)
{
throw;
}
}
}

}
}

0 comments on commit bbf3c26

Please sign in to comment.