/// <summary>
        /// Performs test cleanup.
        /// </summary>
        private static void Cleanup()
        {
            if (File.Exists(ServiceTransaction.FilePathName))
            {
                File.Delete(ServiceTransaction.FilePathName);
            }

            var sourceCodes = new Dictionary <string, string>
            {
                { "WindowsService1", Resources.WindowsService1 },
                { "WindowsService2a", Resources.WindowsService2 },
                { "WindowsService2b", Resources.WindowsService2 }
            };

            var services =
                ServiceHelper_Accessor.GetInstalledServices()
                .Where(p => sourceCodes.Keys.Contains(p.ServiceName));

            foreach (var service in services)
            {
                service.TargetFramework =
                    TargetFramework.Net40;
                service.BinaryPathName =
                    ServiceHelper_Accessor.GetInstalledServiceBinaryPathName(service.ServiceName);

                CleanupServiceInstallation(
                    service,
                    sourceCodes[service.ServiceName]);
            }
        }
        public void Getting_Installed_Services()
        {
            var services = ServiceHelper_Accessor.GetInstalledServices();

            Assert.IsNotNull(services);
            Assert.IsTrue(services.Count > 0);
        }
        public void Installing_And_Uninstalling_Multiple_Service_NET_2()
        {
            const TargetFramework targetFramework = TargetFramework.Net20;

            string binaryPathName = Path.Combine(
                s_basePath,
                "TestWindowsService.exe");

            bool ok = CompileDynamic(
                Resources.WindowsService2,
                binaryPathName,
                "v2.0.50727");

            Assert.IsTrue(ok);

            var services1 = ServiceHelper_Accessor.GetInstalledServices();

            ServiceHelper_Accessor.InstallService(
                targetFramework,
                binaryPathName);

            var services2 = ServiceHelper_Accessor.GetInstalledServices();

            services2.ExceptWith(services1);

            Assert.AreEqual(2, services2.Count);

            ServiceItem serviceItemA = services2.First();

            Assert.AreEqual("WindowsService2a", serviceItemA.ServiceName);
            Assert.AreEqual("[Test] Windows Service #2-A", serviceItemA.DisplayName);

            string actualBinaryPathNameA = ServiceHelper_Accessor.GetInstalledServiceBinaryPathName("WindowsService2a");

            Assert.AreEqual(binaryPathName, actualBinaryPathNameA);

            ServiceItem serviceItemB = services2.Last();

            Assert.AreEqual("WindowsService2b", serviceItemB.ServiceName);
            Assert.AreEqual("[Test] Windows Service #2-B", serviceItemB.DisplayName);

            string actualBinaryPathNameB = ServiceHelper_Accessor.GetInstalledServiceBinaryPathName("WindowsService2a");

            Assert.AreEqual(binaryPathName, actualBinaryPathNameB);

            ServiceHelper_Accessor.UninstallService(
                targetFramework,
                binaryPathName);

            File.Delete(binaryPathName);
        }
        public void Installing_And_Uninstalling_Single_Service_NET_4()
        {
            const TargetFramework targetFramework = TargetFramework.Net40;

            string binaryPathName = Path.Combine(
                s_basePath,
                "TestWindowsService.exe");

            bool ok = CompileDynamic(
                Resources.WindowsService1,
                binaryPathName,
                "v4.0.30319");

            Assert.IsTrue(ok);

            var services1 = ServiceHelper_Accessor.GetInstalledServices();

            ServiceHelper_Accessor.InstallService(
                targetFramework,
                binaryPathName);

            var services2 = ServiceHelper_Accessor.GetInstalledServices();

            services2.ExceptWith(services1);

            Assert.AreEqual(
                1,
                services2.Count);

            ServiceItem serviceItem = services2.First();

            Assert.AreEqual(
                "WindowsService1",
                serviceItem.ServiceName);
            Assert.AreEqual(
                "[Test] Windows Service #1",
                serviceItem.DisplayName);

            string actualBinaryPathName =
                ServiceHelper_Accessor.GetInstalledServiceBinaryPathName("WindowsService1");

            Assert.AreEqual(binaryPathName, actualBinaryPathName);

            ServiceHelper_Accessor.UninstallService(
                targetFramework,
                binaryPathName);

            File.Delete(binaryPathName);
        }