Exemplo n.º 1
0
        public void InstallFailTest()
        {
            InstallerConfiguration config = new InstallerConfiguration();
            MockFailingAction action = new MockFailingAction();
            config.AddAction(action);
            Installer installer = new Installer("", manifest, config);

            ManualResetEvent manualEvent = new ManualResetEvent(false);
            InstallerFailedEventArgs raisedEventArgs = null;
            installer.Failed += delegate(object sender, InstallerFailedEventArgs e)
            {
                raisedEventArgs = e;
                manualEvent.Set();
            };
            installer.Install();
            manualEvent.WaitOne(1000, false);

            Assert.IsNotNull(raisedEventArgs, "Failed event should be fired.");
            Assert.AreEqual(action.Exception, raisedEventArgs.Exception, "Exception should be set.");
        }
Exemplo n.º 2
0
        public void InstallTest()
        {
            InstallerConfiguration config = new InstallerConfiguration();
            MockInstallerAction action = new MockInstallerAction();
            config.AddAction(action);

            Installer installer = new Installer("", manifest, config);

            Assert.IsFalse(action.ActionInstalled);

            Boolean installerCompleted = false;
            ManualResetEvent manualEvent = new ManualResetEvent(false);
            installer.Completed += delegate(object sender, EventArgs e)
            {
                installerCompleted = true;
                manualEvent.Set();
            };
            installer.Install();
            manualEvent.WaitOne(1000, false);

            Assert.IsTrue(installerCompleted, "Installer completed.");
            Assert.IsTrue(action.ActionInstalled, "Action installed.");
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            InstallerConfiguration config = new InstallerConfiguration();
            config.AddAction(new CopyDirAction("scripts", AppPaths.Directory.Scripts));
            config.AddAction(new CopyDirAction("startupscripts", AppPaths.Directory.StartupScripts));
            config.AddAction(new AssignHotkeyAction(Keys.H | Keys.Alt, "", ""));

            JsonFileHandler<InstallerConfiguration> handler = new JsonFileHandler<InstallerConfiguration>();
            handler.Write(new BasePath("C:/temp/scriptcenter/config.installer"), config);
        }
Exemplo n.º 4
0
        public void ProgressTest()
        {
            InstallerConfiguration config = new InstallerConfiguration();
            config.AddAction(new MockInstallerAction());
            config.AddAction(new MockInstallerAction());
            config.AddAction(new MockInstallerAction());

            Installer installer = new Installer("", manifest, config);

            Int32 prevProgress = 0;
            ManualResetEvent manualEvent = new ManualResetEvent(false);
            installer.Progress += delegate(object sender, InstallerProgressEventArgs e)
            {
                Assert.IsTrue(e.Progress > prevProgress);
                prevProgress = e.Progress;
            };
            installer.Completed += delegate(object sender, EventArgs e)
            {
                manualEvent.Set();
            };
            installer.Install();
            manualEvent.WaitOne(1000, false);

            Assert.AreEqual(100, prevProgress, "Installer progress.");
        }