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); }
public void Deleting_Service_Using_Uncommited_Transaction_Info() { string binaryPathName = Path.Combine( s_basePath, "TestWindowsService.exe"); // create log file string log = ServiceTransaction.FilePathName; File.WriteAllText( log, string.Format( Resources.UncommitedInstalledServicesXmlFile, binaryPathName)); // install service const TargetFramework targetFramework = TargetFramework.Net20; bool ok = CompileDynamic( Resources.WindowsService1, binaryPathName, "v2.0.50727"); Assert.IsTrue(ok); ServiceHelper_Accessor.InstallService( targetFramework, binaryPathName); // ensure in successfully installation string actualBinaryPath = ServiceHelper_Accessor.GetInstalledServiceBinaryPathName("WindowsService1"); Assert.AreEqual( binaryPathName, actualBinaryPath); // call test method ServiceHelper.DeletePreviouslyInstalledServices(); // ensure in successfully uninstallation actualBinaryPath = ServiceHelper_Accessor.GetInstalledServiceBinaryPathName("WindowsService1"); Assert.IsNull(actualBinaryPath); }