Ejemplo n.º 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");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 15
0
 public FakeMonitor2(IEnumerable <Tag> tags = null)
 {
     Config = MonitorConfig.Build("test");
     if (tags != null)
     {
         Config = Config.WithTags(tags);
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 18
0
        public void Send_data_when_Reset()
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.Reset();

            gauge.GetValues().Single();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }