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(); }
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(); }
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); }
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); }
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); }
public void TimerOONotNullTest() { var m = new MetricsFactoryBuilder("a", "a").Build().CreateMetric(); var t = m.CreateTimer("foo"); Assert.NotNull(t); }
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)); }