예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }
예제 #5
0
        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();
        }