Пример #1
0
        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();
        }
Пример #2
0
 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);
 }
Пример #3
0
 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();
 }
Пример #4
0
 public void testIsStopped()
 {
     var isOpen = true;
     TsdTimer timer = new TsdTimer("timerName", isOpen);
     Assert.False(timer.IsStopped);
     timer.Stop();
     Assert.True(timer.IsStopped);
 }
Пример #5
0
 public void testConstructor()
 {
     var isOpen = true;
     TsdTimer timer = new TsdTimer("timerName", isOpen);
     Assert.False(timer.IsStopped);
 }
Пример #6
0
 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"));
 }