public void IsRunnableOutsideDisabledTimeFrame() { var dtpMock = MockHelper.CreateDateTimeProviderMock(); dtpMock.Setup(x => x.CurrentTime).Returns(new TimeSpan(15, 55, 0)); var registry = new Mock <IWhenDoRegistry>(); var hangfire = new Mock <IBackgroundJobClient>(); var repository = new MemoryJobRepository(); var manager = new WhenDoJobExecutionManager(dtpMock.Object, registry.Object, MockHelper.CreateLogger <WhenDoJobExecutionManager>(), repository, hangfire.Object); var job = new WhenDoJob(); job.Condition = WhenDoHelpers.ParseExpression <bool>("true", null); job.DisabledFrom = new TimeSpan(10, 0, 0); job.DisabledTill = new TimeSpan(14, 0, 0); Assert.IsTrue(manager.IsRunnable(job, null)); dtpMock.Verify(x => x.CurrentTime, Times.Once); }
public void IsNotRunnableWhenDisabled() { var dtpMock = MockHelper.CreateDateTimeProviderMock(); dtpMock.Setup(x => x.CurrentTime).Returns(new TimeSpan(11, 55, 0)); var registry = new Mock <IWhenDoRegistry>(); var hangfire = new Mock <IBackgroundJobClient>(); var repository = new MemoryJobRepository(); var manager = new WhenDoJobExecutionManager(dtpMock.Object, registry.Object, MockHelper.CreateLogger <WhenDoJobExecutionManager>(), repository, hangfire.Object); var job = new WhenDoJob(); job.Condition = WhenDoHelpers.ParseExpression <bool>("true", null); job.Disabled = true; Assert.IsFalse(manager.IsRunnable(job, null)); job.Disabled = false; Assert.IsTrue(manager.IsRunnable(job, null)); }