public void ItShallStartImplementationAndReportStarted() { // When sut.OnStart(TestStartupArguments, statusReportCallback); // Then A.CallTo(() => serviceImplmentation.Start(TestStartupArguments, A <ServiceStoppedCallback> ._)).MustHaveHappened(); A.CallTo(() => statusReportCallback(ServiceState.Running, ServiceAcceptedControlCommandsFlags.Stop, 0, 0)).MustHaveHappened(); }
public void OnStart(string[] startupArguments, ServiceStatusReportCallback statusReportCallback) { this.statusReportCallback = statusReportCallback; try { serviceImplementation.Start(startupArguments, HandleServiceImplementationStoppedOnItsOwn); statusReportCallback(ServiceState.Running, ServiceAcceptedControlCommandsFlags.Stop, win32ExitCode: 0, waitHint: 0); } catch { statusReportCallback(ServiceState.Stopped, ServiceAcceptedControlCommandsFlags.None, win32ExitCode: -1, waitHint: 0); } }
public void OnStart(string[] startupArguments, ServiceStatusReportCallback statusReportCallback) { _statusReportCallback = statusReportCallback; try { _serviceImplementation.Start(startupArguments, HandleServiceImplementationStoppedOnItsOwn); if (_serviceImplementation.CanPauseAndContinue) { statusReportCallback(ServiceState.Running, ServiceAcceptedControlCommandsFlags.Stop | ServiceAcceptedControlCommandsFlags.PauseContinue, win32ExitCode: 0, waitHint: 0); } else { statusReportCallback(ServiceState.Running, ServiceAcceptedControlCommandsFlags.Stop, win32ExitCode: 0, waitHint: 0); } } catch { statusReportCallback(ServiceState.Stopped, ServiceAcceptedControlCommandsFlags.None, win32ExitCode: -1, waitHint: 0); } }