public void testCreateEmptySinks()
 {
     var metricsFactory = new MetricsFactoryBuilder("test", "test").AddSink(new ISink[0]).Build();
     var metrics = metricsFactory.CreateMetric();
     Assert.NotNull(metrics);
     Assert.That(metrics is TsdMetrics);
     metrics.Dispose();
 }
예제 #2
0
 public void testDecrementByValue()
 {
     var metric = new MetricsFactoryBuilder("", "").Build().CreateMetric();
     var counter = metric.CreateCounter("counterName");
     Assert.AreEqual(0L, counter.Value.Value);
     counter.Decrement(2);
     Assert.AreEqual(-2L, counter.Value.Value);
     counter.Decrement(3);
     Assert.AreEqual(-5L, counter.Value.Value);
 }
 public void testCreate()
 {
     var sink1 = new Mock<ISink>(MockBehavior.Strict);
     var sink2 = new Mock<ISink>(MockBehavior.Strict);
     var metricsFactory = new MetricsFactoryBuilder("test", "test").AddSink(sink1.Object, sink2.Object).Build();
     var metrics = metricsFactory.CreateMetric();
     Assert.NotNull(metrics);
     Assert.That(metrics is TsdMetrics);
     sink1.Setup(l => l.Record(It.IsAny<Sample>()));
     sink2.Setup(l => l.Record(It.IsAny<Sample>()));
     metrics.Dispose();
     sink1.VerifyAll();
     sink2.VerifyAll();
 }
예제 #4
0
 public void testCombination()
 {
     var metric = new MetricsFactoryBuilder("", "").Build().CreateMetric();
     var counter = metric.CreateCounter("counterName");
     Assert.AreEqual(0L, counter.Value.Value);
     counter.Increment();
     Assert.AreEqual(1L, counter.Value.Value);
     counter.Decrement(3L);
     Assert.AreEqual(-2L, counter.Value.Value);
     counter.Increment(4L);
     Assert.AreEqual(2L, counter.Value.Value);
     counter.Decrement();
     Assert.AreEqual(1L, counter.Value.Value);
 }
예제 #5
0
 public void TimerOOValueTest()
 {
     var m = new MetricsFactoryBuilder("a", "a").Build().CreateMetric();
     var t = m.CreateTimer("foo");
     Thread.Sleep(800);
     t.Stop();
     var ratio = ((800e6) / t.Value);
     Assert.True(Math.Abs(ratio-1) < 0.1);
 }
예제 #6
0
 public void TimerOOStoppedTest()
 {
     var m = new MetricsFactoryBuilder("a", "a").Build().CreateMetric();
     var t = m.CreateTimer("foo");
     t.Stop();
     Assert.False(t.IsStarted);
     Assert.True(t.IsStopped);
 }
예제 #7
0
 public void TimerOONotNullTest()
 {
     var m = new MetricsFactoryBuilder("a", "a").Build().CreateMetric();
     var t = m.CreateTimer("foo");
     Assert.NotNull(t);
 }
예제 #8
0
 public void testToString()
 {
     var metric = new MetricsFactoryBuilder("", "").Build().CreateMetric();
     var asString = metric.CreateCounter("counterName").ToString();
     Assert.IsFalse(String.IsNullOrEmpty(asString));
     Assert.AreEqual(0, String.Compare(asString, "counterName", false));
 }