/// <summary> /// Clean up after the test. /// </summary> /// <param name="removeFiles">True if the files should also be removed. False to leave them behind for debugging purposes.</param> private void Cleanup(bool removeFiles) { PackageBuilder.CleanupByUninstalling(); MSIExec.UninstallAllInstalledProducts(); BundleBuilder.CleanupByUninstalling(); MsiVerifier.Reset(); this.ResetRegistry(); this.ResetDirectory(); if (removeFiles) { foreach (FileSystemInfo artifact in this.TestArtifacts) { try { if (artifact is DirectoryInfo) { Directory.Delete(artifact.FullName, true); } else { artifact.Delete(); } } catch { } } } }
/// <summary> /// Uninitializes a single test case. /// </summary> public virtual void TestUninitialize(MethodResult result) { this.TestUninitialize(); BundleBuilder.CleanupByUninstalling(); PackageBuilder.CleanupByUninstalling(); MSIExec.UninstallAllInstalledProducts(); MsiVerifier.Reset(); this.ResetRegistry(); this.ResetDirectory(); if (this.cleanArtifacts) { foreach (FileSystemInfo artifact in this.TestArtifacts) { if (artifact.Exists) { try { DirectoryInfo dir = artifact as DirectoryInfo; if (null != dir) { dir.Delete(true); } else { artifact.Delete(); } } catch { Debug.WriteLine(String.Format("Failed to delete '{0}'.", artifact.FullName)); } } } } }