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;
 }
        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 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);
 }
        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 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 PerfCounterForCallHandlerTestsInstaller()
 {
     countersInstaller = new PerformanceCountersInstaller(PerformanceCounterCallHandlerFixture.TestCategoryName);
     Installers.Add(countersInstaller);
 }