/// <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 { } } } }
protected BundleBuilder CreateBundle(string name, Dictionary <string, string> bindPaths = null, Dictionary <string, string> preprocessorVariables = null, string[] extensions = null) { BundleBuilder builder = new BundleBuilder(this.TestContext.TestName, name, this.TestContext.TestDataDirectory, this.TestContext.TestArtifacts); if (null != bindPaths) { builder.BindPaths = bindPaths; } if (null != preprocessorVariables) { builder.PreprocessorVariables = preprocessorVariables; } builder.Extensions = null == extensions ? WixTestBase.Extensions : extensions; return(builder.Build()); }
/// <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)); } } } } }