Example #1
0
        public void AuditSinkDisposesIngestionApi()
        {
            var api  = new TestIngestionApi();
            var sink = new SeqAuditSink(api);

            Assert.False(api.IsDisposed);

            sink.Dispose();

            Assert.True(api.IsDisposed);
        }
Example #2
0
        public async Task MinimumLevelIsControlled()
        {
            const LogEventLevel originalLevel = LogEventLevel.Debug, newLevel = LogEventLevel.Error;
            var levelSwitch = new LoggingLevelSwitch(originalLevel);
            var api = new TestIngestionApi(_ => Task.FromResult(new IngestionResult(true, HttpStatusCode.Accepted, newLevel)));
            var sink = new BatchedSeqSink(api, null, new ControlledLevelSwitch(levelSwitch));

            await sink.EmitBatchAsync(new[] { Some.InformationEvent() });

            Assert.Equal(newLevel, levelSwitch.MinimumLevel);
        }
Example #3
0
        public void BatchedSinkDisposesIngestionApi()
        {
            var api  = new TestIngestionApi();
            var sink = new BatchedSeqSink(api, null, new ControlledLevelSwitch());

            Assert.False(api.IsDisposed);

            sink.Dispose();

            Assert.True(api.IsDisposed);
        }
Example #4
0
        public async Task EventsAreFormattedIntoPayloads()
        {
            var api  = new TestIngestionApi();
            var sink = new BatchedSeqSink(api, null, new ControlledLevelSwitch());

            await sink.EmitBatchAsync(new[]
            {
                Some.InformationEvent("first"),
                Some.InformationEvent("second")
            });

            var emitted = await api.GetPayloadAsync();

            Assert.Contains("first", emitted.Payload);
            Assert.Contains("second", emitted.Payload);
        }
Example #5
0
        public async Task AuditSinkEmitsIndividualEvents()
        {
            LogEvent evt1 = Some.InformationEvent("first"), evt2 = Some.InformationEvent("second");

            var api  = new TestIngestionApi();
            var sink = new SeqAuditSink(api);

            sink.Emit(evt1);
            sink.Emit(evt2);

            var first = await api.GetPayloadAsync();

            Assert.Contains("first", first.Payload);

            var second = await api.GetPayloadAsync();

            Assert.Contains("second", second.Payload);
        }