Exemplo n.º 1
0
        public void GaugeShouldCallCacheSetGauge()
        {
            //Arrange
            var cacheMock  = new Mock <IMetricsCache>();
            var metricsLog = new RedisMetricsLog(cacheMock.Object);

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

            //Assert
            cacheMock.Verify(mock => mock.SetGauge("gauge_test", 1234), Times.Once());
        }
Exemplo n.º 2
0
        public void TimeShouldNotUpdateMetricIfDeltaIsLessThanZero()
        {
            //Arrange
            var cacheMock  = new Mock <IMetricsCache>();
            var metricsLog = new RedisMetricsLog(cacheMock.Object);

            //Act
            metricsLog.Time("time_test", -1);

            //Assert
            cacheMock.Verify(mock => mock.SetLatency("time_test", -1), Times.Never());
        }
Exemplo n.º 3
0
        public void TimeShouldNotAddMetricIfNoNameSpecified()
        {
            //Arrange
            var cacheMock  = new Mock <IMetricsCache>();
            var metricsLog = new RedisMetricsLog(cacheMock.Object);

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

            //Assert
            cacheMock.Verify(mock => mock.SetLatency("", 1000), Times.Never());
        }
Exemplo n.º 4
0
        public void TimeShouldCallCacheSetLatency()
        {
            //Arrange
            var cacheMock  = new Mock <IMetricsCache>();
            var metricsLog = new RedisMetricsLog(cacheMock.Object);

            //Act
            metricsLog.Time("time_test", 1);

            //Assert
            cacheMock.Verify(mock => mock.SetLatency("time_test", 1), Times.Once());
        }
Exemplo n.º 5
0
        public void CountShouldNotAddMetricIfNoNameSpecified()
        {
            //Arrange
            var cacheMock  = new Mock <IMetricsCache>();
            var metricsLog = new RedisMetricsLog(cacheMock.Object);

            //Act
            metricsLog.Count("", 1);

            //Assert
            cacheMock.Verify(mock => mock.IncrementCount("", 1), Times.Never());
        }
Exemplo n.º 6
0
        public void CountShouldCallCacheIncrementCount()
        {
            //Arrange
            var cacheMock  = new Mock <IMetricsCache>();
            var metricsLog = new RedisMetricsLog(cacheMock.Object);

            //Act
            metricsLog.Count("counter_test", 150);

            //Assert
            cacheMock.Verify(mock => mock.IncrementCount("counter_test", 150), Times.Once());
        }
Exemplo n.º 7
0
        public void CountShouldNotUpdateMetricIfDeltaIsLessOrEqualThanZero()
        {
            //Arrange
            var cacheMock  = new Mock <IMetricsCache>();
            var metricsLog = new RedisMetricsLog(cacheMock.Object);

            //Act
            metricsLog.Count("counter_test", 0);
            metricsLog.Count("counter_test", -1);

            //Assert
            cacheMock.Verify(mock => mock.IncrementCount("counter_test", 0), Times.Never());
            cacheMock.Verify(mock => mock.IncrementCount("counter_test", -1), Times.Never());
        }
Exemplo n.º 8
0
 private void BuildMetricsLog()
 {
     metricsLog = new RedisMetricsLog(metricsCache);
 }