public void CanCreateMultipleCategoriesFromTheCommandLine()
        {
            PerformanceCountersInstaller installer = new PerformanceCountersInstaller();

            CommitInstall(installer, string.Format("/category={0};{1}", firstCategory, secondCategory));

            Assert.IsTrue(PerformanceCounterCategory.Exists(firstCategory));
            Assert.IsTrue(PerformanceCounterCategory.Exists(secondCategory));
        }
        public void CategorySetInCodeOverridesCategorySetOnCommandLine()
        {
            PerformanceCountersInstaller installer = new PerformanceCountersInstaller(secondCategory);

            CommitInstall(installer, string.Format("/category={0}", firstCategory));

            Assert.IsFalse(PerformanceCounterCategory.Exists(firstCategory));
            Assert.IsTrue(PerformanceCounterCategory.Exists(secondCategory));
        }
        public void ShouldBeAbleToSetCategoryViaConstructor()
        {
            PerformanceCountersInstaller installer = new PerformanceCountersInstaller(secondCategory);

            CommitInstall(installer);

            Assert.IsFalse(PerformanceCounterCategory.Exists(firstCategory));
            Assert.IsTrue(PerformanceCounterCategory.Exists(secondCategory));
        }
        public void ShouldInstallFirstCategory()
        {
            PerformanceCountersInstaller installer = GetCommandLineConfiguredInstaller(firstCategory);

            DoCommitInstall(installer);

            PerformanceCounterCategory category = new PerformanceCounterCategory(firstCategory);

            AssertCategoryIsCorrect(category);
        }
        static PerformanceCountersInstaller GetCommandLineConfiguredInstaller(string category)
        {
            PerformanceCountersInstaller installer = new PerformanceCountersInstaller();

            string[]       args    = new string[] { string.Format("/category={0}", category) };
            InstallContext context = new InstallContext(null, args);

            installer.Context = context;
            return(installer);
        }
Beispiel #6
0
        public void ShouldBeAbleToRollbackInstallation()
        {
            PerformanceCountersInstaller installer = GetCommandLineConfiguredInstaller(firstCategory);
            Hashtable savedState = new Hashtable();

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

            Assert.IsFalse(PerformanceCounterCategory.Exists(secondCategory));
        }
        public void CanCreateMultipleCategoriesWithOneInstaller()
        {
            PerformanceCountersInstaller installer =
                new PerformanceCountersInstaller(firstCategory, secondCategory);

            CommitInstall(installer);

            Assert.IsTrue(PerformanceCounterCategory.Exists(firstCategory));
            Assert.IsTrue(PerformanceCounterCategory.Exists(secondCategory));

            AssertCategoryIsCorrect(new PerformanceCounterCategory(firstCategory), firstCategory);
            AssertCategoryIsCorrect(new PerformanceCounterCategory(secondCategory), secondCategory);
        }
        public void ShouldInstallAndUninstallFirstCategory()
        {
            PerformanceCountersInstaller installer = GetCommandLineConfiguredInstaller(firstCategory);

            DoCommitInstall(installer);

            Assert.IsTrue(PerformanceCounterCategory.Exists(firstCategory));

            PerformanceCountersInstaller uninstaller = GetCommandLineConfiguredInstaller(firstCategory);

            uninstaller.Uninstall(null);

            Assert.IsFalse(PerformanceCounterCategory.Exists(firstCategory));
        }
Beispiel #9
0
 private void uninstallPerfCountersButton_Click(object sender, EventArgs e)
 {
     try
     {
         PerformanceCountersInstaller installer = new PerformanceCountersInstaller(new SystemConfigurationSource());
         installer.Context = new InstallContext();
         installer.Uninstall(null);
         MessageBox.Show("Performance counters have been successfully uninstalled.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public void ShouldInstallFirstAndSecondCategories()
        {
            PerformanceCountersInstaller installer = GetCommandLineConfiguredInstaller(firstCategory);

            DoCommitInstall(installer);

            PerformanceCountersInstaller installer2 = GetCommandLineConfiguredInstaller(secondCategory);

            DoCommitInstall(installer2);

            Assert.IsTrue(PerformanceCounterCategory.Exists(firstCategory));
            Assert.IsTrue(PerformanceCounterCategory.Exists(secondCategory));

            AssertCategoryIsCorrect(new PerformanceCounterCategory(secondCategory), secondCategory);
        }
        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));
        }
        public void CanCreateCategoriesFromConfiguration()
        {
            PolicyInjectionSettings settings = new PolicyInjectionSettings();
            PolicyData policyData            = new PolicyData("Perfmon policy");
            //policyData.MatchingRules.Add(new TagAttributeMatchingRuleData("Match By Tag", "Perfmon"));
            PerformanceCounterCallHandlerData counterData = new PerformanceCounterCallHandlerData("{type}.{method}");

            counterData.CategoryName = firstCategory;
            policyData.Handlers.Add(counterData);
            settings.Policies.Add(policyData);

            DictionaryConfigurationSource configSource = new DictionaryConfigurationSource();

            configSource.Add(PolicyInjectionSettings.SectionName, settings);

            PerformanceCountersInstaller installer = new PerformanceCountersInstaller(configSource);

            CommitInstall(installer);

            Assert.IsTrue(PerformanceCounterCategory.Exists(firstCategory));
            Assert.IsFalse(PerformanceCounterCategory.Exists(secondCategory));
        }
        public void ShouldThrowIfNoCategories()
        {
            PerformanceCountersInstaller installer = new PerformanceCountersInstaller();

            CommitInstall(installer);
        }
Beispiel #14
0
 public PerfCounterForCallHandlerTestsInstaller()
 {
     countersInstaller = new PerformanceCountersInstaller(PerformanceCounterCallHandlerFixture.TestCategoryName);
     Installers.Add(countersInstaller);
 }