public void should_get_buffer_segment_when_there_are_segments_available()
        {
            var bufferSegment = _bufferSegmentProvider.GetSegment();

            Check.That(bufferSegment.Length).Equals(_defaultSegmentSize);
            Check.That(new IntPtr(bufferSegment.Data)).IsNotEqualTo(IntPtr.Zero);

            Check.That(_bufferSegmentProvider.LargeBufferCount).Equals(1);
            Check.That(_bufferSegmentProvider.LastSegmentIndex).Equals(0);
        }
Beispiel #2
0
 public void SetUp()
 {
     _bufferSegmentProvider = new BufferSegmentProvider(1024, 1024);
     _logEvent = new LogEvent(_bufferSegmentProvider.GetSegment());
     _output   = new StringBuffer(128)
     {
         Culture = CultureInfo.InvariantCulture
     };
 }
        public void should_log_to_file()
        {
            var bytes                 = new byte[256];
            var message               = "Test log message";
            var byteLength            = Encoding.Default.GetBytes(message, 0, message.Length, bytes, 0);
            var bufferSegmentProvider = new BufferSegmentProvider(1024, 1024);
            var logEvent              = new LogEvent(bufferSegmentProvider.GetSegment());

            logEvent.Initialize(Level.Info, new Log(null, "TestLog"));
            _appender.WriteEvent(logEvent, bytes, byteLength);
            _appender.Flush();

            var written = GetLastLine();

            Check.That(written).IsEqualTo($"{logEvent.Timestamp.Date:yyyy-MM-dd} - {logEvent.Timestamp.TimeOfDay.ToString(@"hh\:mm\:ss\.fff")} - {Thread.CurrentThread.ManagedThreadId} - Info - TestLog || " + message);
        }