Пример #1
0
        public void When_logging_using_debug()
        {
            _logger.Debug("Hi");
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, "Hi", null), Times.Once);

            var ex = new InvalidOperationException();

            _logger.Debug("Ooops", ex);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, "Ooops", ex), Times.Once);

            _logger.DebugFormat("E:{0}", 1);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(2));

            _logger.DebugFormat("E:{0}, {1}", 1, 2);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(3));

            _logger.DebugFormat("E:{0}, {1}, {2}", 1, 2, 3);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(4));

            _logger.DebugFormat("E:{0}, {1}, {2}, {3}, {4}", 1, 2, 3, 4, 5);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(5));

            var italianCulture = new CultureInfo("it-It");
            var date           = new DateTime(2000, 12, 28, 1, 4, 43, 0);

            _logger.DebugFormat(italianCulture, "Date: {0}", date);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(6));
        }
Пример #2
0
        private void TestThroughput()
        {
            Console.WriteLine("------------Testing Throughput------------");

            var  sw      = Stopwatch.StartNew();
            long counter = 0;

            while (sw.Elapsed < _duration)
            {
                counter++;
                _logger.DebugFormat("Counter is: {0}", counter.ToString());
            }

            Console.WriteLine("Counter reached: {0:n0}, Time Taken: {1}", counter, sw.Elapsed.ToString());
        }