예제 #1
0
        public void ItShallStartImplementationAndReportStarted()
        {
            // When
            sut.OnStart(TestStartupArguments, statusReportCallback);

            // Then
            A.CallTo(() => serviceImplmentation.Start(TestStartupArguments, A <ServiceStoppedCallback> ._)).MustHaveHappened();
            A.CallTo(() => statusReportCallback(ServiceState.Running, ServiceAcceptedControlCommandsFlags.PauseContinueStop, 0, 0)).MustHaveHappened();
        }
예제 #2
0
        public void OnStart(string[] startupArguments, ServiceStatusReportCallback statusReportCallback)
        {
            this.statusReportCallback = statusReportCallback;

            try
            {
                serviceImplementation.Start(startupArguments, HandleServiceImplementationStoppedOnItsOwn);

                statusReportCallback(ServiceState.Running, ServiceAcceptedControlCommandsFlags.PauseContinueStop, win32ExitCode: 0, waitHint: 0);
            }
            catch
            {
                statusReportCallback(ServiceState.Stopped, ServiceAcceptedControlCommandsFlags.None, win32ExitCode: -1, waitHint: 0);
            }
        }