示例#1
0
        public void ShouldBeAbleToRollbackInstallation()
        {
            PerformanceCountersInstaller installer = GetCommandLineConfiguredInstaller(firstCategory);
            Hashtable savedState = new Hashtable();

            installer.Install(savedState);
            installer.Rollback(savedState);

            Assert.IsFalse(PerformanceCounterCategory.Exists(secondCategory));
        }
示例#2
0
 private void installPerfCountersButton_Click(object sender, EventArgs e)
 {
     try
     {
         PerformanceCountersInstaller installer = new PerformanceCountersInstaller(new SystemConfigurationSource());
         IDictionary state = new System.Collections.Hashtable();
         installer.Context = new InstallContext();
         installer.Install(state);
         installer.Commit(state);
         MessageBox.Show("Performance counters have been successfully installed.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public void ShouldBeAbleToRollbackInstallation()
        {
            PerformanceCountersInstaller installer = GetCommandLineConfiguredInstaller(firstCategory);
            Hashtable savedState = new Hashtable();

            try
            {
                installer.Install(savedState);
            }
            catch (SecurityException ex)
            {
                Assert.Inconclusive("In order to run the tests, please run Visual Studio as Administrator.\r\n{0}", ex.ToString());
            }
            installer.Rollback(savedState);

            Assert.IsFalse(PerformanceCounterCategory.Exists(secondCategory));
        }