예제 #1
0
        public void Value_is_called_value()
        {
            var monitor = new PerformanceCounterMonitor(MonitorConfig.Build("Test"),
                                                        PerformanceCounterConfig.Build("Process", "Private Bytes", Process.GetCurrentProcess().ProcessName));

            monitor.GetValues().Single().Name.Should().Be("value");
        }
예제 #2
0
        public void Consists_of_a_single_monitor()
        {
            var gauge = new MinGauge(MonitorConfig.Build("Test"));

            gauge.GetAllMonitors().Should().HaveCount(1);
            gauge.GetAllMonitors().Single().Should().BeSameAs(gauge);
        }
예제 #3
0
        public void Do_not_send_data_and_reset_when_nothing_registered()
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
            ((IGauge <long>)gauge).GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
        }
예제 #4
0
        public void Performance_counter_consists_of_a_single_value()
        {
            var monitor = new PerformanceCounterMonitor(MonitorConfig.Build("Test"),
                                                        PerformanceCounterConfig.Build("Process", "Private Bytes", Process.GetCurrentProcess().ProcessName));

            monitor.GetValues().Should().HaveCount(1);
        }
예제 #5
0
        public void Health_check_consists_of_a_single_monitor()
        {
            var healthCheck = new HealthCheck(MonitorConfig.Build("Test"), () => true);

            healthCheck.GetAllMonitors().Should().HaveCount(1);
            healthCheck.GetAllMonitors().Single().Should().BeSameAs(healthCheck);
        }
예제 #6
0
        public void Consists_of_a_single_monitor()
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.GetAllMonitors().Should().HaveCount(1);
            counter.GetAllMonitors().Single().Should().BeSameAs(counter);
        }
예제 #7
0
        public void Do_not_send_data_and_reset_when_nothing_registered()
        {
            var timer = new TimerAbsentFilter(new Timer(MonitorConfig.Build("Test")));

            timer.GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
            ((ITimer)timer).GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
        }
예제 #8
0
        public void Do_not_send_data_when_nothing_registered()
        {
            var counter = new CounterAbsentFilter <long>(new Counter(MonitorConfig.Build("Test")));

            counter.GetValues().ShouldBeEquivalentTo(new IMeasurement[0]);
            ((ICounter <long>)counter).GetValues().ShouldBeEquivalentTo(new IMeasurement[0]);
        }
예제 #9
0
        public void Send_data_when_registered(int someValue)
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.Set(someValue);

            gauge.GetValues().Single();
        }
예제 #10
0
        public void Send_data_when_registered(int someValue)
        {
            var timer = new TimerAbsentFilter(new Timer(MonitorConfig.Build("Test")));

            timer.Register(TimeSpan.FromSeconds(someValue));

            timer.GetValues().Any().Should().BeTrue();
        }
예제 #11
0
        public void FilterCounter_send_data_when_registered_as_incrementamount(int someValue)
        {
            var counter = new CounterAbsentFilter <long>(new Counter(MonitorConfig.Build("Test")));

            counter.Increment(someValue);

            counter.GetValues().Single();
        }
예제 #12
0
        public void Updating_the_value_updates_the_value_correctly(double expectedValue)
        {
            var gauge = new DecimalGauge(MonitorConfig.Build("Test"));

            gauge.Set(new decimal(expectedValue));

            gauge.GetValues().First().Value.Should().Be(new decimal(expectedValue));
        }
예제 #13
0
        public void Updating_the_value_updates_the_value_correctly(long expectedValue)
        {
            var gauge = new LongGauge(MonitorConfig.Build("Test"));

            gauge.Set(expectedValue);

            gauge.GetValue().Should().Be(expectedValue);
        }
예제 #14
0
        public void After_get_and_reset_the_value_is_still_gotten_from_func(int expectedValue)
        {
            var gauge = new Gauge <int>(MonitorConfig.Build("Test"), () => expectedValue);

            gauge.GetValuesAndReset();

            gauge.GetValuesAndReset().First().Value.Should().Be(expectedValue);
        }
예제 #15
0
 public FakeMonitor2(IEnumerable <Tag> tags = null)
 {
     Config = MonitorConfig.Build("test");
     if (tags != null)
     {
         Config = Config.WithTags(tags);
     }
 }
예제 #16
0
        public void Send_data_when_registered_as_function()
        {
            var timer = new TimerAbsentFilter(new Timer(MonitorConfig.Build("Test")));

            timer.Record(() => 42);

            timer.GetValues().Any().Should().BeTrue();
        }
예제 #17
0
        public void Send_data_when_registered_as_elapsed()
        {
            var timer = new TimerAbsentFilter(new Timer(MonitorConfig.Build("Test")));

            timer.RegisterElapsed(new System.Diagnostics.Stopwatch());

            timer.GetValues().Any().Should().BeTrue();
        }
예제 #18
0
        public void Send_data_when_Reset()
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.Reset();

            gauge.GetValues().Single();
        }
예제 #19
0
        public void Send_data_and_reset_when_registered()
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.Set(33);

            gauge.GetValuesAndReset().Single();
        }
예제 #20
0
        public void Config_with_multiple_tags_in_one_call_has_all_the_tags_specified()
        {
            var expectedTags = new[] { new Tag("key", "value"), new Tag("key2", "value") };

            var config = MonitorConfig.Build("Anything").WithTags(expectedTags);

            config.Tags.Should().BeEquivalentTo(expectedTags);
        }
예제 #21
0
        public void FilterCounter_send_data_and_reset_when_registered()
        {
            var counter = new CounterAbsentFilter <long>(new Counter(MonitorConfig.Build("Test")));

            counter.Increment();

            counter.GetValuesAndReset().Single();
        }
예제 #22
0
        public void Incrementing_the_counters_works_as_expected(int amount)
        {
            var counter = new CumulativeCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            counter.GetValues().First().Value.Should().Be(amount);
        }
예제 #23
0
        public void Incrementing_the_counters_works_as_expected(int amount)
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            counter.GetValue().Should().Be(amount);
        }
예제 #24
0
        public void Get_and_reset_gets_the_maximum_value()
        {
            const long expected = 100L;
            var        gauge    = new MinGauge(MonitorConfig.Build("Test"));

            gauge.Set(expected);

            gauge.GetValueAndReset().Should().Be(expected);
        }
예제 #25
0
        public void Supplying_value_greater_than_previously_record_updates_the_value()
        {
            const long expectedValue = 1000;
            var        gauge         = new MaxGauge(MonitorConfig.Build("Test"));

            gauge.Set(expectedValue);

            gauge.GetValues().First().Value.Should().Be(expectedValue);
        }
예제 #26
0
        public void Get_and_reset_sets_the_value_to_zero()
        {
            var gauge = new MinGauge(MonitorConfig.Build("Test"));

            gauge.Set(100L);

            gauge.GetValueAndReset();

            gauge.GetValue().Should().Be(0L);
        }
예제 #27
0
        public void Config_with_single_tag_specified_has_the_tag_attached()
        {
            const string key   = "key";
            const string value = "value";

            var config = MonitorConfig.Build("Anything").WithTag(new Tag(key, value));

            config.Tags.Should().HaveCount(1)
            .And.OnlyContain(x => x.Key == key && x.Value == value);
        }
예제 #28
0
        public void Get_and_reset_returns_the_value(int amount)
        {
            var counter = new CumulativeCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            var value = counter.GetValuesAndReset();

            value.First().Value.Should().Be(amount);
        }
예제 #29
0
        public void Get_and_reset_does_not_reset_the_value(int amount)
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            counter.GetValueAndReset();

            counter.GetValue().Should().Be(amount);
        }
예제 #30
0
        public void Get_and_reset_sets_the_value_to_zero()
        {
            var gauge = new DecimalGauge(MonitorConfig.Build("Test"));

            gauge.Set(100L);

            gauge.GetValuesAndReset().ToList();

            gauge.GetValues().First().Value.Should().Be(0L);
        }