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); }
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>())); }
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); }
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); }