示例#1
0
        public void Should_dequeue_all_when_disposing()
        {
            var worker = new TestProcessor();
            var target = new WorkerThread <int>("test", TimeSpan.FromDays(1), worker.Process);

            target.Enqueue(1);
            target.Enqueue(2);
            target.Enqueue(3);

            target.Dispose();

            worker.Logs.Should().Have.SameSequenceAs(new[] {
                "1, 2, 3"
            });
        }
示例#2
0
        public void Should_be_able_to_dispose_failing_worker()
        {
            var worker = new TestProcessor();
            var target = new WorkerThread <int>("test", TimeSpan.FromDays(1), worker.Process);

            target.Enqueue(1);

            target.Dispose();

            worker.Logs.Should().Have.SameSequenceAs(new[] {
                "1"
            });
        }
示例#3
0
        public void Should_dequeue_in_batch()
        {
            var worker = new TestProcessor();
            var target = new WorkerThread <int>("test", TimeSpan.FromSeconds(.75), worker.Process);

            target.Enqueue(1);
            target.Enqueue(2);
            target.Enqueue(3);

            worker.Go.WaitOne();

            target.Enqueue(4);
            target.Enqueue(5);
            target.Enqueue(6);

            worker.Go.WaitOne();

            worker.Logs.Should().Have.SameSequenceAs(new[] {
                "1, 2, 3",
                "4, 5, 6"
            });
        }
示例#4
0
 protected override void Append(LoggingEvent loggingEvent)
 {
     loggingEvent.Fix = FixFlags.All;
     _worker.Enqueue(loggingEvent);
 }