public void Should_write_drained_events()
        {
            var e = CreateLogEvent();

            events.TryAdd(e);

            WriteEvents().Should().BeTrue();

            writer.Received(1).WriteEvents(buffer, 1);
        }
        public void Should_eventually_write_added_events()
        {
            var e = CreateEvent();

            muxer.TryLog(e, new ConsoleLogSettings());

            new Action(() => eventsWriter.Received().WriteEvents(
                           Arg.Is <LogEventInfo[]>(events =>
                                                   events.Length == 1 && ReferenceEquals(events[0].Event, e)), 1))
            .ShouldPassIn(10.Seconds());
        }
Esempio n. 3
0
        public void ObtainWriterAsync_should_dispose_old_writer()
        {
            ObtainWriter();

            settings = new FileLogSettings {
                OutputBufferSize = 42
            };
            ObtainWriter();

            eventsWriter.Received().Dispose();
        }
        public void TryAdd_should_wait_for_buffer_space_if_specified()
        {
            singleFileWorker = new SingleFileWorker();
            muxer            = new SingleFileMuxer(writerProviderFactory, singleFileWorker, new FileLogSettings
            {
                WaitIfQueueIsFull   = true,
                EventsQueueCapacity = 1
            });

            for (var i = 0; i < 10; i++)
            {
                muxer.TryAdd(CreateEventInfo(), false).Should().BeTrue();
            }

            muxer.Dispose();

            eventsWriter.Received(10)
            .WriteEvents(
                Arg.Any <LogEventInfo[]>(),
                Arg.Is(1));
        }