mirror of
https://github.com/Radarr/Radarr
synced 2024-12-24 17:01:38 +00:00
Merge branch 'master' of git://github.com/kayone/NzbDrone
This commit is contained in:
commit
4d7bb451f2
3 changed files with 55 additions and 1 deletions
|
@ -231,6 +231,40 @@ public void Init_Timers_only_registers_once()
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Count(1, timers);
|
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 class BrokenJob : IJob
|
||||||
{
|
{
|
||||||
public string Name
|
public string Name
|
||||||
|
|
|
@ -14,6 +14,8 @@ public interface IJob
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default Interval that this job should run at. In seconds.
|
/// Default Interval that this job should run at. In seconds.
|
||||||
/// </summary>
|
/// </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; }
|
int DefaultInterval { get; }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ public virtual void Initialize()
|
||||||
{
|
{
|
||||||
var settings = new JobSetting
|
var settings = new JobSetting
|
||||||
{
|
{
|
||||||
Enable = true,
|
Enable = timerProviderLocal.DefaultInterval > 0,
|
||||||
TypeName = timer.GetType().ToString(),
|
TypeName = timer.GetType().ToString(),
|
||||||
Name = timerProviderLocal.Name,
|
Name = timerProviderLocal.Name,
|
||||||
Interval = timerProviderLocal.DefaultInterval,
|
Interval = timerProviderLocal.DefaultInterval,
|
||||||
|
|
Loading…
Reference in a new issue