2011-11-07 07:26:21 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Jobs;
|
2011-11-07 07:26:21 +01:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public class FakeJob : IJob
|
|
|
|
|
{
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return GetType().Name; }
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-15 03:47:23 +01:00
|
|
|
|
public virtual TimeSpan DefaultInterval
|
2011-11-07 07:26:21 +01:00
|
|
|
|
{
|
2012-01-15 03:47:23 +01:00
|
|
|
|
get { return TimeSpan.FromMinutes(15); }
|
2011-11-07 07:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int ExecutionCount { get; private set; }
|
|
|
|
|
|
|
|
|
|
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
|
|
|
|
{
|
|
|
|
|
ExecutionCount++;
|
|
|
|
|
Console.WriteLine("Begin " + Name);
|
|
|
|
|
Start();
|
|
|
|
|
Console.WriteLine("End " + Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Start()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DisabledJob : FakeJob
|
|
|
|
|
{
|
2012-01-15 03:47:23 +01:00
|
|
|
|
public override TimeSpan DefaultInterval
|
2011-11-07 07:26:21 +01:00
|
|
|
|
{
|
2012-01-15 03:47:23 +01:00
|
|
|
|
get { return TimeSpan.FromTicks(0); }
|
2011-11-07 07:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BrokenJob : FakeJob
|
|
|
|
|
{
|
|
|
|
|
protected override void Start()
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException("Broken job is broken");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class SlowJob : FakeJob
|
|
|
|
|
{
|
|
|
|
|
protected override void Start()
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|