aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/AdvancedInstaller_TST.cs
blob: b883db7b7fd305fb0db65705f60a38bfccfc1881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comme
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);
        }
    }
}