public void Run_service() { MockRepository mocks = new MockRepository(); IApplicationSettings settings = mocks.CreateMock <IApplicationSettings>(); IServiceAgentAggregator aggregator = mocks.CreateMock <IServiceAgentAggregator>(); IServiceRunner runner = new ServiceRunner(aggregator, settings); using (mocks.Record()) { aggregator.ExecuteServiceAgentCycle(); LastCall.Repeat.Times(2, int.MaxValue); Expect.Call(settings.GetServiceSleepTime()).Return(10); LastCall.Repeat.Times(2, int.MaxValue); } using (mocks.Playback()) { runner.Start(); Thread.Sleep(500); runner.Stop(); } mocks.VerifyAll(); }
private void workerThreadStart() { try { Logger.Debug(this, "Service Runner thread initializing"); while (_continue) { Logger.Debug(this, "Service Runner thread initialized"); RunOneCycle(); int sleepTime = _applicationSettings.GetServiceSleepTime(); Thread.Sleep(sleepTime); } } catch (Exception ex) { Logger.Fatal(this, "Running service cycle failed", ex); } }