public static void ClassCleanup()
        {
            var counters = new PmcCreationData();

            counters.Add(typeof(TestCounter2));
            PmcManager.RemovePerformanceCounters(counters);
        }
        public static void ClassInitialize(TestContext context)
        {
            var counters = new PmcCreationData();

            counters.Add(typeof(TestCounter2));
            PmcManager.InstallPerformanceCounters(counters);
        }
Esempio n. 3
0
        public void AddFailsWithInvalidType()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            // --- Act
            pmcData.Add(typeof(int));
        }
Esempio n. 4
0
        public void DuplicatedCategoryNameOnSameCategoryWorks()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            // --- Act
            pmcData.Add(typeof(FaultyCategory1));
            pmcData.Add(typeof(FaultyCategory1));
        }
Esempio n. 5
0
        public void DuplicatedCategoryNameRaisesException()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            // --- Act
            pmcData.Add(typeof(FaultyCategory1));
            pmcData.Add(typeof(FaultyCategory2));
        }
Esempio n. 6
0
        public void DuplicatedCounterNameFails()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            // --- Act
            pmcData.Add(typeof(TestCounter1));
            pmcData.Add(typeof(TestCounter1));
        }
        public void UsingRemoveWithWrongCounterFails()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            pmcData.Add(typeof(TestProcessorTimePmc));

            // --- Act
            var result = PmcManager.RemovePerformanceCounters(pmcData);

            // --- Assert
            result.Errors.ShouldHaveCountOf(1);
        }
        public void UsingInstallWithWrongCounterFails()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            pmcData.Add(typeof(TestCounter7));

            // --- Act
            var result = PmcManager.InstallPerformanceCounters(pmcData);

            // --- Assert
            result.Errors.ShouldHaveCountOf(1);
        }
Esempio n. 9
0
        public void CounterInAssemblyProcessedAsExpected()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            pmcData.MergeCountersFromAssembly(typeof(PmcCreationData).Assembly);

            // --- Act
            var result = PmcManager.InstallPerformanceCounters(pmcData);

            // --- Assert
            result.InstalledCategories.ShouldHaveCountOf(2);
            result.Errors.ShouldHaveCountOf(0);
        }
Esempio n. 10
0
        public void MissingCategoryNameFails()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            // --- Act
            try
            {
                pmcData.Add(typeof(FaultyCategory3));
                Assert.Fail();
            }
            catch (TargetInvocationException ex)
            {
                ex.InnerException.ShouldBeOfType(typeof(KeyNotFoundException));
            }
        }
Esempio n. 11
0
        public void DataCreationWorksAsExpected()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            // --- Act
            pmcData.Add(typeof(TestCounter1));
            pmcData.Add(typeof(TestCounter2));
            pmcData.Add(typeof(TestCounter3));
            pmcData.Add(typeof(TestCounter4));
            pmcData.Add(typeof(TestCounter5));
            pmcData.Add(typeof(TestCounter6));
            var counters1 = pmcData.GetCounters("TestCategory1");
            var counters2 = pmcData.GetCounters("TestCategory2");
            var counters3 = pmcData.GetCounters("TestCategory3");

            // --- Assert
            pmcData.Categories.ShouldHaveCountOf(3);
            pmcData.Categories.ContainsKey("TestCategory1").ShouldBeTrue();
            pmcData.Categories.ContainsKey("TestCategory2").ShouldBeTrue();
            pmcData.Categories.ContainsKey("TestCategory3").ShouldBeTrue();

            counters1.ShouldHaveCountOf(2);
            counters1["TestCounter1"].Name.ShouldEqual("TestCounter1");
            counters1["TestCounter1"].Help.ShouldEqual("TestCounter1 Help");
            counters1["TestCounter1"].Type.ShouldEqual(PerformanceCounterType.NumberOfItems64);

            counters1["TestCounter2"].Name.ShouldEqual("TestCounter2");
            counters1["TestCounter2"].Help.ShouldEqual("TestCounter2 Help");
            counters1["TestCounter2"].Type.ShouldEqual(PerformanceCounterType.NumberOfItems32);

            counters2["TestCounter3"].Name.ShouldEqual("TestCounter3");
            counters2["TestCounter3"].Help.ShouldEqual("");
            counters2["TestCounter3"].Type.ShouldEqual(PerformanceCounterType.NumberOfItems32);

            counters2["TestCounter4"].Name.ShouldEqual("TestCounter4");
            counters2["TestCounter4"].Help.ShouldEqual("TestCounter4 Help");
            counters2["TestCounter4"].Type.ShouldEqual(PerformanceCounterType.ElapsedTime);

            counters3["TestCounter5"].Name.ShouldEqual("TestCounter5");
            counters3["TestCounter5"].Help.ShouldEqual("TestCounter5 Help");
            counters3["TestCounter5"].Type.ShouldEqual(PerformanceCounterType.NumberOfItems32);

            counters3["TestCounter6"].Name.ShouldEqual("TestCounter6");
            counters3["TestCounter6"].Help.ShouldEqual("");
            counters3["TestCounter6"].Type.ShouldEqual(PerformanceCounterType.NumberOfItems32);
        }
Esempio n. 12
0
        public void ClearWorksAsExpected()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            pmcData.Add(typeof(TestCounter1));
            pmcData.Add(typeof(TestCounter2));
            pmcData.Add(typeof(TestCounter3));
            pmcData.Add(typeof(TestCounter4));
            pmcData.Add(typeof(TestCounter5));
            pmcData.Add(typeof(TestCounter6));

            // --- Act
            pmcData.Clear();

            // --- Assert
            pmcData.Categories.ShouldHaveCountOf(0);
        }
        public void InstallWorksAsExpected()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            pmcData.Add(typeof(TestCounter1));
            pmcData.Add(typeof(TestCounter2));
            pmcData.Add(typeof(TestCounter3));
            pmcData.Add(typeof(TestCounter4));
            pmcData.Add(typeof(TestCounter5));
            pmcData.Add(typeof(TestCounter6));

            // --- Act
            var results = PmcManager.InstallPerformanceCounters(pmcData);

            // --- Assert
            results.InstalledCategories.ShouldHaveCountOf(3);
            results.Errors.ShouldHaveCountOf(0);
        }
        public void MultipleInstanceWork()
        {
            // --- Arrange
            var pmcData = new PmcCreationData();

            pmcData.Add(typeof(TestCounter1));
            pmcData.Add(typeof(TestCounter2));
            PmcManager.InstallPerformanceCounters(pmcData);

            // --- Act
            var inst1 = PmcManager.GetCounter <TestCounter1>("1");
            var inst2 = PmcManager.GetCounter <TestCounter1>("2");

            inst1.RawValue = 10;
            inst2.RawValue = 20;

            // --- Assert
            inst1.RawValue.ShouldEqual(10);
            inst2.RawValue.ShouldEqual(20);
        }