Example #1
0
        public void TestCorruptedServiceInPanicWillOverrideDisabledUpdates()
        {
            var merged = false;

            var service = new ServiceController() {
                Packages = new MockServicePackageManager() {
                    PackageInstalled = (sender, uri, packageId) => merged = true
                },
                Settings = {
                    ServiceUpdateCore = false
                },
                ServiceLoaderProxyType = typeof(MockNonSerializableServiceLoaderProxy),
                Observer = {
                    Status = ServiceStatusType.None
                }
            };

            service.Panic();

            Assert.IsTrue(merged);

            service.Dispose();
        }
Example #2
0
        public void TestCorruptedServiceInPanicWillOverrideDisabledUpdatesAndRecover()
        {
            var merged = false;

            ServiceController service = null;

            service = new ServiceController() {
                Packages = new MockServicePackageManager() {
                    PackageInstalled = (sender, uri, packageId) => {
                        merged = true;
                        // ReSharper disable AccessToModifiedClosure
                        // We only do this to keep the test concise.
                        if (service != null) {
                            service.ServiceLoaderProxyType = typeof(MockServiceLoaderProxy);
                        }
                        // ReSharper restore AccessToModifiedClosure

                    }
                },
                Settings = {
                    ServiceUpdateCore = false
                },
                ServiceLoaderProxyType = typeof(MockNonSerializableServiceLoaderProxy),
                Observer = {
                    Status = ServiceStatusType.None
                }
            };

            service.Panic();

            Assert.IsTrue(merged);
            Assert.AreEqual(ServiceStatusType.Started, service.Observer.Status);

            service.Dispose();
        }
Example #3
0
        public void TestStoppedHealthyServiceInPanicWillRestart()
        {
            var service = new ServiceController() {
                Packages = new MockServicePackageManager(),
                Settings = {
                    ServiceUpdateCore = true
                },
                ServiceLoaderProxyType = typeof(MockServiceLoaderProxy)
            };

            service.Panic();

            Assert.AreEqual(ServiceStatusType.Started, service.Observer.Status);

            service.Dispose();
        }
Example #4
0
        public void TestStoppedHealthyServiceInPanicWillNotUpdateWithUpdatesDisabled()
        {
            var merged = false;

            var service = new ServiceController() {
                Packages = new MockServicePackageManager() {
                    PackageInstalled = (sender, uri, packageId) => merged = true
                },
                Settings = {
                    ServiceUpdateCore = false
                },
                ServiceLoaderProxyType = typeof(MockServiceLoaderProxy),
                Observer = {
                    Status = ServiceStatusType.None
                }
            };

            service.Panic();

            Assert.IsFalse(merged);

            service.Dispose();
        }