예제 #1
0
        public void BufferedLoggerRestartsTask()
        {
            var logger         = new SlowLogger();
            var bufferedLogger = new BufferedLogger(logger, 10, BufferExceededBehaviors.Lock);

            bufferedLogger.Log(new LogEntry()
            {
                Message = "msg1"
            });
            while (logger.LoggedEntries.Count < 1)
            {
                ;
            }
            bufferedLogger.Log(new LogEntry()
            {
                Message = "msg2"
            });
        }
예제 #2
0
        public void BufferedLoggerDontLockup()
        {
            var logger         = new SlowLogger();
            var bufferedLogger = new BufferedLogger(logger, 10, BufferExceededBehaviors.Lock);

            Task.Run(() =>
            {
                for (int n = 0; n < 100; n++)
                {
                    bufferedLogger.Log(new LogEntry()
                    {
                        Message = n.ToString()
                    });
                }
            });

            logger.TestFinished.WaitOne(1000);

            Assert.Equal(100, logger.LoggedEntries.Count);
        }