コード例 #1
0
        public void GaugeShouldUpdateMetricWhenExisting()
        {
            //Arrange
            var gauges     = new ConcurrentDictionary <string, long>();
            var cache      = new InMemoryMetricsCache(null, null, gauges);
            var metricsLog = new InMemoryMetricsLog(null, cache);

            //Act
            metricsLog.Gauge("gauge_test", 1234);
            metricsLog.Gauge("gauge_test", 4567);

            //Assert
            long gauge = cache.GetGauge("gauge_test");

            Assert.AreEqual(4567, gauge);
        }
コード例 #2
0
        public void SendGaugeMetricsSuccessfully()
        {
            //Arrange
            var gauges = new ConcurrentDictionary <string, long>();
            var metricsApiClientMock = new Mock <IMetricsSdkApiClient>();
            var cache      = new InMemoryMetricsCache(null, null, gauges);
            var metricsLog = new InMemoryMetricsLog(metricsApiClientMock.Object, cache, 1);

            //Act
            metricsLog.Gauge("gauge_test", 1234);

            //Assert
            metricsApiClientMock.Verify(x => x.SendGaugeMetrics(It.IsAny <string>()));
        }
コード例 #3
0
        public void GaugeShouldNotAddMetricIfNoNameSpecified()
        {
            //Arrange
            var gauges     = new ConcurrentDictionary <string, long>();
            var cache      = new InMemoryMetricsCache(null, null, gauges);
            var metricsLog = new InMemoryMetricsLog(null, cache);

            //Act
            metricsLog.Gauge("", 1000);

            //Assert
            long gauge = cache.GetGauge("");

            Assert.AreEqual(0, gauge);
        }
コード例 #4
0
        public void GaugeShouldNotUpdateMetricIfDeltaIsLessThanZero()
        {
            //Arrange
            var gauges     = new ConcurrentDictionary <string, long>();
            var cache      = new InMemoryMetricsCache(null, null, gauges);
            var metricsLog = new InMemoryMetricsLog(null, cache);

            //Act
            metricsLog.Gauge("gauge_test", -1);

            //Assert
            long gauge = cache.GetGauge("gauge_test");

            Assert.AreEqual(0, gauge);
        }