Added a unit tests that reproduces the bug fixed in the previous commit
git-svn-id: file:///srv/devel/repo-conversion/nusu@153 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
f8adca9e17
commit
ce9a6bc932
|
@ -207,8 +207,7 @@ namespace Nuclex.Support.Scheduling {
|
||||||
ITimeSource timeSource = Scheduler.CreateTimeSource(true);
|
ITimeSource timeSource = Scheduler.CreateTimeSource(true);
|
||||||
try {
|
try {
|
||||||
Assert.That(timeSource is WindowsTimeSource);
|
Assert.That(timeSource is WindowsTimeSource);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
IDisposable disposableTimeSource = timeSource as IDisposable;
|
IDisposable disposableTimeSource = timeSource as IDisposable;
|
||||||
if(disposableTimeSource != null) {
|
if(disposableTimeSource != null) {
|
||||||
disposableTimeSource.Dispose();
|
disposableTimeSource.Dispose();
|
||||||
|
@ -224,8 +223,7 @@ namespace Nuclex.Support.Scheduling {
|
||||||
ITimeSource timeSource = Scheduler.CreateTimeSource(false);
|
ITimeSource timeSource = Scheduler.CreateTimeSource(false);
|
||||||
try {
|
try {
|
||||||
Assert.That(timeSource is GenericTimeSource);
|
Assert.That(timeSource is GenericTimeSource);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
IDisposable disposableTimeSource = timeSource as IDisposable;
|
IDisposable disposableTimeSource = timeSource as IDisposable;
|
||||||
if(disposableTimeSource != null) {
|
if(disposableTimeSource != null) {
|
||||||
disposableTimeSource.Dispose();
|
disposableTimeSource.Dispose();
|
||||||
|
@ -241,8 +239,7 @@ namespace Nuclex.Support.Scheduling {
|
||||||
ITimeSource timeSource = Scheduler.CreateDefaultTimeSource();
|
ITimeSource timeSource = Scheduler.CreateDefaultTimeSource();
|
||||||
try {
|
try {
|
||||||
Assert.IsNotNull(timeSource);
|
Assert.IsNotNull(timeSource);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
IDisposable disposableTimeSource = timeSource as IDisposable;
|
IDisposable disposableTimeSource = timeSource as IDisposable;
|
||||||
if(disposableTimeSource != null) {
|
if(disposableTimeSource != null) {
|
||||||
disposableTimeSource.Dispose();
|
disposableTimeSource.Dispose();
|
||||||
|
@ -439,6 +436,25 @@ namespace Nuclex.Support.Scheduling {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reproduction case for a bug that occurred when the final notification in
|
||||||
|
/// the scheduler was cancelled (call to PriorityQueue.Peek() on empty queue)
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestCancelFinalNotification() {
|
||||||
|
MockTimeSource mockTimeSource = new MockTimeSource(new DateTime(2010, 1, 1));
|
||||||
|
using(TestSubscriber subscriber = new TestSubscriber()) {
|
||||||
|
using(Scheduler scheduler = new Scheduler(mockTimeSource)) {
|
||||||
|
scheduler.Cancel(
|
||||||
|
scheduler.NotifyIn(TimeSpan.FromHours(12), subscriber.Callback)
|
||||||
|
);
|
||||||
|
|
||||||
|
mockTimeSource.AdvanceTime(TimeSpan.FromHours(14));
|
||||||
|
Thread.Sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Returns the provided date/time value as a utc time value</summary>
|
/// <summary>Returns the provided date/time value as a utc time value</summary>
|
||||||
/// <param name="dateTime">Date/time value that will be returned as UTC</param>
|
/// <param name="dateTime">Date/time value that will be returned as UTC</param>
|
||||||
/// <returns>The provided date/time value as UTC</returns>
|
/// <returns>The provided date/time value as UTC</returns>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user