Пример #1
0
        public void TestDisposeServiceDispatchedEndDelegateCalled()
        {
            var end = false;

            var service = new ServiceController() {
                ServiceLoaderProxy = new MockServiceLoaderProxy(),
                DisposeServiceEnd = controller => end = true
            };

            service.DisposeService();

            Assert.IsTrue(end);

            service.Dispose();
        }
Пример #2
0
        public void TestDisposeServiceDispatchedBeginDelegateCalled()
        {
            var begin = false;

            var service = new ServiceController() {
                ServiceLoaderProxy = new MockServiceLoaderProxy(),
                DisposeServiceBegin = controller => begin = true
            };

            service.DisposeService();

            Assert.IsTrue(begin);

            service.Dispose();
        }
Пример #3
0
        public void TestDisposeServiceDispatchedSuccess()
        {
            var disposed = false;

            var service = new ServiceController() {
                ServiceLoaderProxy = new MockServiceLoaderProxy() {
                    OnDisposeHandler = () => disposed = true
                }
            };

            service.DisposeService();

            Assert.IsTrue(disposed);

            service.Dispose();
        }
Пример #4
0
        public void TestServiceLoaderProxyNulled()
        {
            var service = new ServiceController() {
                ServiceLoaderProxy = new MockServiceLoaderProxy()
            };

            service.DisposeService();

            Assert.IsNull(service.ServiceLoaderProxy);

            service.Dispose();
        }
Пример #5
0
        public void TestExceptionLoggedOnTimeout()
        {
            var service = new ServiceController() {
                ServiceLoaderProxy = new MockSlowServiceLoaderProxy() {
                    DisposeSleep = 500
                },
                Settings = {
                    DisposeServiceTimeout = 10
                }
            };

            service.DisposeService();

            Assert.IsNotEmpty(Defines.ErrorsLogsDirectory.GetFiles());
            Assert.Greater(Defines.ErrorsLogsDirectory.GetFiles().First().Length, 0);

            service.Dispose();
        }
Пример #6
0
        public void TestExceptionLogged()
        {
            var service = new ServiceController() {
                ServiceLoaderProxy = new MockNonSerializableServiceLoaderProxy()
            };

            service.DisposeService();

            Assert.IsNotEmpty(Defines.ErrorsLogsDirectory.GetFiles());
            Assert.Greater(Defines.ErrorsLogsDirectory.GetFiles().First().Length, 0);

            service.Dispose();
        }