コード例 #1
0
        public void HasBlockingBehavior()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            _logger.Info("Via no-blocking mechanism.");
            stopwatch.Stop();
            var noblockingCallDuration = stopwatch.Elapsed.TotalMilliseconds;

            stopwatch = Stopwatch.StartNew();
            try
            {
                _logger.AsBlockingLogger(TimeSpan.FromMilliseconds(10000))
                .Info("Via blocking mechanism.")
                ;
            }
            catch (TimeoutException ex)
            {
                Assert.Fail("The timeout should be large enough for this test!", ex);
            }
            stopwatch.Stop();
            var blockingCallDuration = stopwatch.Elapsed.TotalMilliseconds;

            Assert.IsTrue(blockingCallDuration > (10 * noblockingCallDuration));
        }