using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using Tango.AdvancedInstaller; using Tango.Core.IO; namespace Tango.UnitTesting.AdvancedInstaller { [TestClass] [TestCategory("Advanced Installer")] public class AdvancedInstaller_TST { [TestMethod] public void Build_Install_Verify() { var demo_project_path = Directory.GetCurrentDirectory() + "\\AdvancedInstaller\\DemoProject"; var project_Path = Path.Combine(demo_project_path, "DemoProject.aip"); var files_path = Path.Combine(demo_project_path, "Files"); var added_file = files_path + "\\addedFile.txt"; InstallerBuilder builder = new InstallerBuilder(project_Path); File.WriteAllText(added_file, "Added File!"); var output_folder = TemporaryManager.Default.CreateFolder(); String product_name = builder.GetProperty(ProjectProperty.ProductName).Result; String manufacturer = builder.GetProperty(ProjectProperty.Manufacturer).Result; var output_file = output_folder + "\\" + product_name + " Installer_v2.0.0.msi"; builder.Build("2.0.0", output_file).Wait(); File.Delete(added_file); Assert.IsTrue(File.Exists(output_file)); var process = Process.Start(output_file); process.WaitForExit(); File.Delete(output_file); String installationFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), manufacturer, product_name); Assert.IsTrue(File.Exists(Path.Combine(installationFolder, Path.GetFileName(added_file)))); Thread.Sleep(2000); bool installed = builder.IsInstalled().Result; Assert.IsTrue(installed); builder.Uninstall().Wait(); Thread.Sleep(2000); installed = builder.IsInstalled().Result; Assert.IsFalse(installed); } } }