public void testGetElapsedAfterStop() { var logger = new Mock<ILog>(MockBehavior.Strict); var isOpen = true; TsdTimer timer = new TsdTimer("timerName", isOpen, logger.Object); logger.Setup(l => l.Error(It.IsAny<Action<Common.Logging.FormatMessageHandler>>())); var elap = timer.Elapsed; logger.VerifyAll(); }
public void testClose() { int minimumTimeInMilliseconds = 100; long startTime = DateTime.Now.Ticks; ITimer timer = new TsdTimer("timerName", true); Assert.NotNull(timer); Thread.Sleep(minimumTimeInMilliseconds); timer.Dispose(); long elapsedTimeInNanoseconds = (long)((DateTime.Now.Ticks - startTime) *100); Assert.GreaterOrEqual(timer.Value, minimumTimeInMilliseconds * 1e6); Assert.LessOrEqual(timer.Value, elapsedTimeInNanoseconds); }
public void testStopAfterMetricsClosed() { var isOpen = true; var logger = new Mock<ILog>(MockBehavior.Strict); TsdTimer timer = new TsdTimer("timerName", isOpen, logger.Object); timer.Dispose(); logger.Setup(l => l.Error(It.IsAny<Action<Common.Logging.FormatMessageHandler>>())); timer.Stop(); logger.VerifyAll(); }
public void testIsStopped() { var isOpen = true; TsdTimer timer = new TsdTimer("timerName", isOpen); Assert.False(timer.IsStopped); timer.Stop(); Assert.True(timer.IsStopped); }
public void testConstructor() { var isOpen = true; TsdTimer timer = new TsdTimer("timerName", isOpen); Assert.False(timer.IsStopped); }
public void testToString() { var isOpen = true; String asString = new TsdTimer("timerName", isOpen).ToString(); Assert.NotNull(asString); Assert.False(String.IsNullOrEmpty(asString)); Assert.That(asString.Contains("timerName")); }