public void SetGaugeShouldAddNewMetricWhenNotExisting() { //Arrange var redisAdapterMock = new Mock <IRedisAdapter>(); redisAdapterMock.Setup(x => x.Set(metricsGaugeKeyPrefix + "gauge_test", "150")); redisAdapterMock.Setup(x => x.Get(metricsGaugeKeyPrefix + "gauge_test")).Returns("150"); var cache = new RedisMetricsCache(redisAdapterMock.Object, "10.0.0.1", "net-1.0.2"); //Act cache.SetGauge("gauge_test", 150); //Assert long gauge = cache.GetGauge("gauge_test"); Assert.IsNotNull(gauge); Assert.AreEqual(150, gauge); }
public void SetGaugeShouldUpdateMetricWhenExisting() { //Arrange var redisAdapterMock = new Mock <IRedisAdapter>(); redisAdapterMock.Setup(x => x.Set(metricsGaugeKeyPrefix + "gauge_test", "1234")); redisAdapterMock.Setup(x => x.Set(metricsGaugeKeyPrefix + "gauge_test", "4567")); redisAdapterMock.Setup(x => x.Get(metricsGaugeKeyPrefix + "gauge_test")).Returns("4567"); var cache = new RedisMetricsCache(redisAdapterMock.Object, "10.0.0.1", "net-1.0.2"); //Act cache.SetGauge("gauge_test", 1234); cache.SetGauge("gauge_test", 4567); //Assert long gauge = cache.GetGauge("gauge_test"); Assert.AreEqual(4567, gauge); }