public void if_a_metric_is_being_queried_for_the_second_time_it_returns_a_measured_value()
        {
            var mockPerformanceCounter = new Mock<IPerformanceCounter>();
            mockPerformanceCounter.Setup(m => m.NextValue()).Returns(5.0f);

            var mockPerformanceCounterCategoryRepository = new Mock<IPerformanceCounterCategoryRepository>();
            mockPerformanceCounterCategoryRepository.Setup(m => m.GetInstances(It.IsAny<string>())).Returns(new[] { "foo" });

            var source = new PerformanceCounterSource(new PerformanceCounterRegistryTestHarness(_registryDictionary, (a, b, c) => mockPerformanceCounter.Object), mockPerformanceCounterCategoryRepository.Object);

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            source.QueryValue("\\category(*)\\counter").ToList();
            var samples = source.QueryValue("\\category(*)\\counter").ToList();

            Assert.That(samples.Count, Is.EqualTo(1));
            Assert.That(samples.First().Value, Is.EqualTo(5.0f));
        }
        public void when_querying_for_a_metric_in_a_particular_instances_then_the_instances_do_not_need_to_be_read()
        {
            var mockPerformanceCounter = new Mock<IPerformanceCounter>();
            var mockPerformanceCounterCategoryRepository = new Mock<IPerformanceCounterCategoryRepository>();
            mockPerformanceCounterCategoryRepository.Setup(m => m.GetInstances(It.IsAny<string>())).Returns(new[] { "foo" });

            var source = new PerformanceCounterSource(new PerformanceCounterRegistryTestHarness(_registryDictionary, (a, b, c) => mockPerformanceCounter.Object), mockPerformanceCounterCategoryRepository.Object);

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            source.QueryValue("\\category(instance)\\counter").ToList();

            mockPerformanceCounterCategoryRepository.Verify(m => m.GetInstances(It.IsAny<string>()), Times.Never);
        }
        public void if_a_metric_is_being_queried_for_the_first_time_it_returns_no_value()
        {
            var mockPerformanceCounter = new Mock<IPerformanceCounter>();
            mockPerformanceCounter.Setup(m => m.NextValue()).Returns(5.0f);

            var mockPerformanceCounterCategoryRepository = new Mock<IPerformanceCounterCategoryRepository>();
            mockPerformanceCounterCategoryRepository.Setup(m => m.GetInstances(It.IsAny<string>())).Returns(new[] { "foo" });

            var source = new PerformanceCounterSource(new PerformanceCounterRegistryTestHarness(_registryDictionary, (a, b, c) => mockPerformanceCounter.Object), mockPerformanceCounterCategoryRepository.Object);

            var samples = source.QueryValue("\\category(*)\\counter").ToList();

            Assert.That(samples.Count, Is.EqualTo(0));
        }