public void ThrowManualFlushWithBypass()
        {
            var outputMock = new Mock <IDirectOutput>();
            var flushMock  = new Mock <IRecordFlusher>();
            var serpent    = new SerpentKernel.Kernel(flushMock.Object, outputMock.Object);
            var newEntry   = new SerpentEntry(String.Empty);

            serpent.ForceFlushOnRecord = true;

            Assert.Throws <InvalidFlushOperationException>(() => serpent.FlushRecords());
        }
Пример #2
0
        public void ThrowOnInvalidSeverityRange()
        {
            var outputMock = new Mock <IDirectOutput>();
            var flushMock  = new Mock <IRecordFlusher>();
            var serpent    = new SerpentKernel.Kernel(flushMock.Object, outputMock.Object);
            var newEntry   = new SerpentEntry(String.Empty);

            serpent.MinimumSeverity = EntrySeverity.Critical;
            serpent.MaximumSeverity = EntrySeverity.Low;

            Assert.Throws <InvalidSeverityRangeException>(() => serpent.Record(newEntry));
        }
Пример #3
0
        public void PassRecordWhenSeverityIsMaximum()
        {
            var outputMock = new Mock <IDirectOutput>();
            var flushMock  = new Mock <IRecordFlusher>();
            var serpent    = new SerpentKernel.Kernel(flushMock.Object, outputMock.Object);
            var newEntry   = new SerpentEntry(String.Empty, EntrySeverity.Critical);

            serpent.MaximumSeverity = EntrySeverity.Critical;
            serpent.Record(newEntry);

            Assert.NotEmpty(serpent.GetRecords());
        }
Пример #4
0
        public void FailRecordWhenSeverityLowerThanMinimum()
        {
            var outputMock = new Mock <IDirectOutput>();
            var flushMock  = new Mock <IRecordFlusher>();
            var serpent    = new SerpentKernel.Kernel(flushMock.Object, outputMock.Object);
            var newEntry   = new SerpentEntry(String.Empty, EntrySeverity.Medium);

            serpent.MinimumSeverity = EntrySeverity.High;
            serpent.Record(newEntry);

            Assert.Empty(serpent.GetRecords());
        }
        public void PassFlushWithBypass()
        {
            var outputMock = new Mock <IDirectOutput>();
            var flushMock  = new Mock <IRecordFlusher>();
            var serpent    = new SerpentKernel.Kernel(flushMock.Object, outputMock.Object);
            var newEntry   = new SerpentEntry(String.Empty);

            serpent.ForceFlushOnRecord = true;

            serpent.Record(newEntry);

            flushMock.Verify(x => x.FlushSingleEntry(It.IsAny <ISerpentEntry>()));
        }
        public void PassFlushWithoutBypass()
        {
            var outputMock = new Mock <IDirectOutput>();
            var flushMock  = new Mock <IRecordFlusher>();
            var serpent    = new SerpentKernel.Kernel(flushMock.Object, outputMock.Object);
            var newEntry   = new SerpentEntry(String.Empty);

            serpent.ForceFlushOnRecord = false;
            serpent.Record(newEntry);

            Assert.NotEmpty(serpent.GetRecords());
            serpent.FlushRecords();
            Assert.Empty(serpent.GetRecords());
            flushMock.Verify(x => x.FlushSingleEntry(It.IsAny <ISerpentEntry>()), Times.Never);
        }