public void TestExceptionLoggedWhenPollingThrowsException() { var service = new ServiceController() { ServiceLoaderProxy = new MockNonSerializableServiceLoaderProxy(), Settings = { ServiceUpdateCore = false }, Observer = { Status = ServiceStatusType.Started }, ServiceLoaderProxyType = typeof(MockServiceLoaderProxy) }; service.Polling_Tick(null); Assert.IsNotEmpty(Defines.ErrorsLogsDirectory.GetFiles()); Assert.Greater(Defines.ErrorsLogsDirectory.GetFiles().First().Length, 0); service.Dispose(); }
public void TestNotPolledWhenServiceIsStopped() { var signaled = false; var service = new ServiceController() { ServiceLoaderProxy = new MockServiceLoaderProxy() { WaitingMessage = new ServiceMessage() { Name = "help" } }, SignalBegin = (controller, message) => { signaled = true; }, Settings = { ServiceUpdateCore = false }, Observer = { Status = ServiceStatusType.Stopped }, ServiceLoaderProxyType = typeof(MockServiceLoaderProxy) }; service.Polling_Tick(null); Assert.IsFalse(signaled); service.Dispose(); }
public void TestPollingRecievedMessageDoesNotRestart() { var stopped = false; var started = false; var service = new ServiceController() { ServiceLoaderProxy = new MockServiceLoaderProxy() { WaitingMessage = new ServiceMessage() { Name = "help" } }, Settings = { ServiceUpdateCore = false }, Observer = { Status = ServiceStatusType.Started, StatusChange = (observer, type) => { if (type == ServiceStatusType.Started) started = true; if (type == ServiceStatusType.Stopped) stopped = true; } }, ServiceLoaderProxyType = typeof(MockServiceLoaderProxy) }; service.Polling_Tick(null); Assert.IsFalse(stopped); Assert.IsFalse(started); service.Dispose(); }
public void TestServiceRestartWhenPollingThrowsException() { var stopped = false; var started = false; var service = new ServiceController() { ServiceLoaderProxy = new MockNonSerializableServiceLoaderProxy(), Settings = { ServiceUpdateCore = false }, Observer = { Status = ServiceStatusType.Started, StatusChange = (observer, type) => { if (type == ServiceStatusType.Started) started = true; if (type == ServiceStatusType.Stopped) stopped = true; } }, ServiceLoaderProxyType = typeof(MockServiceLoaderProxy) }; service.Polling_Tick(null); Assert.IsTrue(stopped); Assert.IsTrue(started); service.Dispose(); }
public void TestNotPolledWhenServiceProxyIsNull() { var signaled = false; var service = new ServiceController() { SignalBegin = (controller, message) => { signaled = true; }, Settings = { ServiceUpdateCore = false }, Observer = { Status = ServiceStatusType.Started }, ServiceLoaderProxyType = typeof(MockServiceLoaderProxy) }; service.Polling_Tick(null); Assert.IsFalse(signaled); service.Dispose(); }