fixed a concurrency issue with job provider.

This commit is contained in:
kay.one 2011-05-19 23:25:39 -07:00
commit 0d02b0538b
2 changed files with 29 additions and 3 deletions

View file

@ -100,6 +100,29 @@ namespace NzbDrone.Core.Test
}
[Test]
//This test will confirm that the concurrency checks are rest
//after execution so the job can successfully run.
public void no_concurent_jobs()
{
IEnumerable<IJob> fakeJobs = new List<IJob> { new SlowJob() };
var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository());
mocker.SetConstant(fakeJobs);
var timerProvider = mocker.Resolve<JobProvider>();
timerProvider.Initialize();
var firstRun = timerProvider.QueueJob(typeof(SlowJob),1);
var secondRun = timerProvider.QueueJob(typeof(SlowJob),2);
var third = timerProvider.QueueJob(typeof(SlowJob),3);
Thread.Sleep(10000);
}
[Test]
//This test will confirm that the concurrency checks are rest
//after execution so the job can successfully run.
@ -436,8 +459,10 @@ namespace NzbDrone.Core.Test
public void Start(ProgressNotification notification, int targetId)
{
Console.WriteLine("Starting Job");
Thread.Sleep(2000);
ExexutionCount++;
Console.WriteLine("Finishing Job");
}
}
}