Example #1
0
		public void AggregateLogWriter_RequiresSynchronisation_IsFalse()
		{
			var child = new MockLogWriter();
			var logWriter = new AsyncQueueLogWriter(child, 10, TimeSpan.Zero, null);

			Assert.AreEqual(false, logWriter.RequiresSynchronization);
		}
        public void AggregateLogWriter_RequiresSynchronisation_IsFalseIfNoChildRequires()
        {
            var child1    = new MockLogWriter();
            var child2    = new MockLogWriter();
            var logWriter = new AggregateLogWriter(new ILogWriter[] { child1, child2 });

            Assert.AreEqual(false, logWriter.RequiresSynchronization);
        }
        public void AggregateLogWriter_RequiresSynchronisation_IsTrueIfAnyChildRequires()
        {
            var child1 = new MockLogWriter();
            var child2 = new MockLogWriter();

            child2.SetRequiresSynchronisation(true);
            var logWriter = new AggregateLogWriter(new ILogWriter[] { child1, child2 });

            Assert.AreEqual(true, logWriter.RequiresSynchronization);
        }
        public void FilteredWriter_WriteEvent_DoesNotWriteEventWhenFilterFails()
        {
            var mockWriter = new MockLogWriter();
            var logWriter  = new Writers.FilteringLogWriter(new Filters.LogSeverityFilter(LogEventSeverity.Error), mockWriter);
            var logEvent   = new LogEvent()
            {
                EventName = "Test"
            };

            logWriter.Write(logEvent);
            Assert.AreEqual(null, mockWriter.LastEvent);
        }
        public void FilteredWriter_WriteEvent_WritesEventWhenFilterPasses()
        {
            var mockWriter = new MockLogWriter();
            var logWriter  = new Writers.FilteringLogWriter(new Filters.LogSeverityFilter(LogEventSeverity.Error), mockWriter);

            var logEvent = new LogEvent()
            {
                EventName = "Test"
            };

            logEvent.EventSeverity = LogEventSeverity.Error;
            logWriter.Write(logEvent);
            Assert.AreEqual(logEvent, mockWriter.LastEvent);
        }
        public void AggregateLogWriter_WriteEvent_WritesToMultipleChildren()
        {
            var child1    = new MockLogWriter();
            var child2    = new MockLogWriter();
            var logWriter = new AggregateLogWriter(new ILogWriter[] { child1, child2 });
            var logEvent  = new LogEvent()
            {
                EventName = "Test"
            };

            logWriter.Write(logEvent);

            Assert.AreEqual(logEvent, child1.LastEvent);
            Assert.AreEqual(logEvent, child2.LastEvent);
        }
 public void FilteredWriter_Constructor_ThrowsOnNullLogWriter()
 {
     var mockWriter = new MockLogWriter();
     var logWriter  = new Writers.FilteringLogWriter(new Filters.LogSeverityFilter(LogEventSeverity.Error), null);
 }
 public void FilteredWriter_Constructor_ThrowsOnNullFilter()
 {
     var mockWriter = new MockLogWriter();
     var logWriter  = new Writers.FilteringLogWriter(null, mockWriter);
 }