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."); }
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."); }
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); }
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."); }