public void SchedulerRunnerDbStartAndWaitWithDelayBetweenTasksTest() { InitDb(); SchedulerConfigurationSection configuration = GetConfiguration(true); configuration.SecondsBetweenSchedulerTasks = 60; var languages = new List <string> { "en", "ru" }; var mocks = new Mockery(); var configStrategy = mocks.NewMock <ISchedulerConfigurationStrategy>(); Expect.Once.On(configStrategy).Method("GetAVRFacade").Will(Return.Value(new AVRFacade(m_Container))); Expect.Once.On(configStrategy).Method("GetConfigurationSection").Will(Return.Value(configuration)); Expect.Once.On(configStrategy).Method("GetLanguages").Will(Return.Value(languages)); Expect.Once.On(configStrategy).Method("GetServiceDisplayName").Will(Return.Value("service name")); Container c = new Container(); c.Configure(r => { r.For <ISchedulerConfigurationStrategy>().Use(configStrategy); }); using (var runner = c.GetInstance <SchedulerRunner>()) { runner.Start(); Thread.Sleep(200); } mocks.VerifyAllExpectationsHaveBeenMet(); }
private static SchedulerConfigurationSection GetConfiguration(bool immediatelyRunSchedulerWhenServiceStarts) { var configuration = new SchedulerConfigurationSection { TimeOfSchedulerRuns = new TimeSpan(0, 0, 0, 0), ImmediatelyRunScheduler = immediatelyRunSchedulerWhenServiceStarts, SecondsBetweenSchedulerTasks = 0, }; return(configuration); }
public void SchedulerRunnerFakeMissedTaskTickTest() { var mocks = new Mockery(); var facade = mocks.NewMock <IAVRFacade>(); Expect.Once.On(facade).Method("GetQueryIdList").Will(Return.Value(new List <long> { 1, 2, 3 })); Expect.Exactly(6).On(facade).Method("RefreshCachedQueryTableByScheduler"); Expect.Exactly(6).On(facade).Method("DeleteQueryCacheForLanguage"); Expect.Exactly(3).On(facade).Method("GetsQueryCacheUserRequestDate").Will(Return.Value(DateTime.Now)); SchedulerConfigurationSection configuration = GetConfiguration(false); var languages = new List <string> { "en", "ru" }; ISchedulerConfigurationStrategy configStrategy = mocks.NewMock <ISchedulerConfigurationStrategy>(); Expect.Once.On(configStrategy).Method("GetAVRFacade").Will(Return.Value(facade)); Expect.Once.On(configStrategy).Method("GetConfigurationSection").Will(Return.Value(configuration)); Expect.Once.On(configStrategy).Method("GetLanguages").Will(Return.Value(languages)); Expect.Once.On(configStrategy).Method("GetServiceDisplayName").Will(Return.Value("service name")); Container c = new Container(); c.Configure(r => { r.For <ISchedulerConfigurationStrategy>().Use(configStrategy); }); using (var runner = c.GetInstance <SchedulerRunner>()) { runner.Start(); Thread.Sleep(50); runner.QueryRefreshTimerTick(null); } mocks.VerifyAllExpectationsHaveBeenMet(); }
public void RefreshedCacheOnUserCallAfterDaysTest() { var configuration = new SchedulerConfigurationSection { TimeOfSchedulerRuns = new TimeSpan(0, 0, 0, 0), ImmediatelyRunScheduler = false, RefreshedCacheOnUserCallAfterDays = 1, SecondsBetweenSchedulerTasks = 0, }; var mocks = new Mockery(); var configStrategy = mocks.NewMock <ISchedulerConfigurationStrategy>(); Expect.Once.On(configStrategy).Method("GetConfigurationSection").Will(Return.Value(configuration)); Expect.Once.On(configStrategy).Method("GetServiceDisplayName").Will(Return.Value("service name")); Container c = new Container(); c.Configure(r => { r.For <ISchedulerConfigurationStrategy>().Use(configStrategy); }); Assert.AreEqual(1, (c.GetInstance <AVRFacade>()).RefreshedCacheOnUserCallAfterDays); mocks.VerifyAllExpectationsHaveBeenMet(); }
public void SchedulerRunnerFakeDisabledTest() { var mocks = new Mockery(); SchedulerConfigurationSection configuration = GetConfiguration(true); configuration.SchedulerEnabled = false; var configStrategy = mocks.NewMock <ISchedulerConfigurationStrategy>(); Expect.Once.On(configStrategy).Method("GetConfigurationSection").Will(Return.Value(configuration)); Expect.Once.On(configStrategy).Method("GetServiceDisplayName").Will(Return.Value("service name")); Container c = new Container(); c.Configure(r => { r.For <ISchedulerConfigurationStrategy>().Use(configStrategy); }); using (var runner = c.GetInstance <SchedulerRunner>()) { runner.Start(); Thread.Sleep(50); runner.QueryRefreshTimerTick(null); } mocks.VerifyAllExpectationsHaveBeenMet(); }
public DefaultScheduler(SchedulerConfigurationSection section, DefaultSchedulerOptions options) { Section = section; Options = options; }