public void UninstallTest() { InstallerConfiguration config = new InstallerConfiguration(); MockInstallerAction action = new MockInstallerAction(); config.AddAction(action); Installer installer = new Installer("", manifest, config); Assert.IsFalse(action.ActionUninstalled); Boolean installerCompleted = false; ManualResetEvent manualEvent = new ManualResetEvent(false); installer.Completed += delegate(object sender, EventArgs e) { installerCompleted = true; manualEvent.Set(); }; installer.Uninstall(); manualEvent.WaitOne(1000, false); Assert.IsTrue(installerCompleted, "Installer completed."); Assert.IsTrue(action.ActionUninstalled, "Action uninstalled."); }
public void UninstallFailTest() { 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.Uninstall(); manualEvent.WaitOne(1000, false); Assert.IsNotNull(raisedEventArgs, "Failed event should be fired."); Assert.AreEqual(action.Exception, raisedEventArgs.Exception, "Exception should be set."); }