public void CountShouldNotUpdateMetricIfDeltaIsLessOrEqualThanZero() { //Arrange var counters = new ConcurrentDictionary <string, Counter>(); var cache = new InMemoryMetricsCache(counters); var metricsLog = new InMemoryMetricsLog(null, cache); //Act metricsLog.Count("counter_test", 0); metricsLog.Count("counter_test", -1); //Assert Counter counter = cache.GetCount("counter_test"); Assert.IsNull(counter); }
public void CountShouldUpdateMetricWhenExisting() { //Arrange var counters = new ConcurrentDictionary <string, Counter>(); var cache = new InMemoryMetricsCache(counters); var metricsLog = new InMemoryMetricsLog(null, cache); //Act metricsLog.Count("counter_test", 150); metricsLog.Count("counter_test", 10); //Assert Counter counter = cache.GetCount("counter_test"); Assert.AreEqual(2, counter.GetCount()); Assert.AreEqual(160, counter.GetDelta()); }
public void SendCountMetricsSuccessfully() { //Arrange var counters = new ConcurrentDictionary <string, Counter>(); var metricsApiClientMock = new Mock <IMetricsSdkApiClient>(); var cache = new InMemoryMetricsCache(counters); var metricsLog = new InMemoryMetricsLog(metricsApiClientMock.Object, cache, 1); //Act metricsLog.Count("counter_test", 150); //Assert metricsApiClientMock.Verify(x => x.SendCountMetrics(It.IsAny <string>())); }
public void CountShouldNotAddMetricIfNoNameSpecified() { //Arrange var counters = new ConcurrentDictionary <string, Counter>(); var cache = new InMemoryMetricsCache(counters); var metricsLog = new InMemoryMetricsLog(null, cache); //Act metricsLog.Count("", 1); //Assert Counter counter = cache.GetCount(""); Assert.IsNull(counter); }