1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 20:12:41 +02:00

Added a quick patch to support disabled by default jobs. setting interval to 0 will disable the job

This commit is contained in:
Keivan 2011-05-11 11:25:32 -07:00
parent 24c47801b3
commit 3083ff6fcf
3 changed files with 55 additions and 1 deletions

View File

@ -231,6 +231,40 @@ public void Init_Timers_only_registers_once()
//Assert
Assert.Count(1, timers);
Assert.IsTrue(timers[0].Enable);
}
[Test]
public void Init_Timers_sets_interval_0_to_disabled()
{
var repo = MockLib.GetEmptyRepository();
for (int i = 0; i < 2; i++)
{
var disabledJob = new DisabledJob();
IEnumerable<IJob> fakeTimers = new List<IJob> { disabledJob };
var mocker = new AutoMoqer();
mocker.SetConstant(repo);
mocker.SetConstant(fakeTimers);
var timerProvider = mocker.Resolve<JobProvider>();
timerProvider.Initialize();
}
var mocker2 = new AutoMoqer();
mocker2.SetConstant(repo);
var assertTimerProvider = mocker2.Resolve<JobProvider>();
var timers = assertTimerProvider.All();
//Assert
Assert.Count(1, timers);
Assert.IsFalse(timers[0].Enable);
}
@ -255,6 +289,24 @@ public void Start(ProgressNotification notification, int targetId)
}
}
public class DisabledJob : IJob
{
public string Name
{
get { return "DisabledJob"; }
}
public int DefaultInterval
{
get { return 0; }
}
public void Start(ProgressNotification notification, int targetId)
{
}
}
public class BrokenJob : IJob
{
public string Name

View File

@ -14,6 +14,8 @@ public interface IJob
/// <summary>
/// Default Interval that this job should run at. In seconds.
/// </summary>
/// <remarks>Setting this value to 0 means the job will not be
/// executed by the schedule and is only triggered manually.</remarks>
int DefaultInterval { get; }

View File

@ -208,7 +208,7 @@ public virtual void Initialize()
{
var settings = new JobSetting
{
Enable = true,
Enable = timerProviderLocal.DefaultInterval > 0,
TypeName = timer.GetType().ToString(),
Name = timerProviderLocal.Name,
Interval = timerProviderLocal.DefaultInterval,