public void TestManagementOfSchedulerListeners() { TestSchedulerListener tl1 = new TestSchedulerListener(); TestSchedulerListener tl2 = new TestSchedulerListener(); ListenerManagerImpl manager = new ListenerManagerImpl(); // test adding listener without matcher manager.AddSchedulerListener(tl1); Assert.AreEqual(1, manager.GetSchedulerListeners().Count, "Unexpected size of listener list"); // test adding listener with matcher manager.AddSchedulerListener(tl2); Assert.AreEqual(2, manager.GetSchedulerListeners().Count, "Unexpected size of listener list"); // test removing a listener manager.RemoveSchedulerListener(tl1); Assert.AreEqual(1, manager.GetSchedulerListeners().Count, "Unexpected size of listener list"); }
public void TestSchedulerFactoryObjectWithListeners() { IJobFactory jobFactory = new AdaptableJobFactory(); IScheduler scheduler = (IScheduler)mockery.CreateMock(typeof(IScheduler)); ISchedulerListener schedulerListener = new TestSchedulerListener(); IJobListener globalJobListener = new TestJobListener(); IJobListener jobListener = new TestJobListener(); ITriggerListener globalTriggerListener = new TestTriggerListener(); ITriggerListener triggerListener = new TestTriggerListener(); Expect.Call(scheduler.JobFactory = (jobFactory)); scheduler.AddSchedulerListener(schedulerListener); scheduler.AddGlobalJobListener(globalJobListener); scheduler.AddJobListener(jobListener); scheduler.AddGlobalTriggerListener(globalTriggerListener); scheduler.AddTriggerListener(triggerListener); scheduler.Start(); scheduler.Shutdown(false); mockery.ReplayAll(); SchedulerFactoryObject schedulerFactoryObject = new TestSchedulerFactoryObject(scheduler); schedulerFactoryObject.JobFactory = (jobFactory); schedulerFactoryObject.SchedulerListeners = (new ISchedulerListener[] { schedulerListener }); schedulerFactoryObject.GlobalJobListeners = (new IJobListener[] { globalJobListener }); schedulerFactoryObject.JobListeners = (new IJobListener[] { jobListener }); schedulerFactoryObject.GlobalTriggerListeners = (new ITriggerListener[] { globalTriggerListener }); schedulerFactoryObject.TriggerListeners = (new ITriggerListener[] { triggerListener }); try { schedulerFactoryObject.AfterPropertiesSet(); schedulerFactoryObject.Start(); } finally { schedulerFactoryObject.Dispose(); } mockery.VerifyAll(); }
public void TestSchedulerFactoryObjectWithListeners() { IJobFactory jobFactory = new AdaptableJobFactory(); IScheduler scheduler = MockRepository.GenerateMock<IScheduler>(); ISchedulerListener schedulerListener = new TestSchedulerListener(); IJobListener globalJobListener = new TestJobListener(); IJobListener jobListener = new TestJobListener(); ITriggerListener globalTriggerListener = new TestTriggerListener(); ITriggerListener triggerListener = new TestTriggerListener(); Expect.Call(scheduler.JobFactory = (jobFactory)); scheduler.AddSchedulerListener(schedulerListener); scheduler.AddGlobalJobListener(globalJobListener); scheduler.AddJobListener(jobListener); scheduler.AddGlobalTriggerListener(globalTriggerListener); scheduler.AddTriggerListener(triggerListener); scheduler.Start(); scheduler.Shutdown(false); SchedulerFactoryObject schedulerFactoryObject = new TestSchedulerFactoryObject(scheduler); schedulerFactoryObject.JobFactory = (jobFactory); schedulerFactoryObject.SchedulerListeners = (new ISchedulerListener[] {schedulerListener}); schedulerFactoryObject.GlobalJobListeners = (new IJobListener[] {globalJobListener}); schedulerFactoryObject.JobListeners = (new IJobListener[] {jobListener}); schedulerFactoryObject.GlobalTriggerListeners = (new ITriggerListener[] {globalTriggerListener}); schedulerFactoryObject.TriggerListeners = (new ITriggerListener[] {triggerListener}); try { schedulerFactoryObject.AfterPropertiesSet(); schedulerFactoryObject.Start(); } finally { schedulerFactoryObject.Dispose(); } }