public void verify_few_log_messages() { // Prepare listener to receive messages var opts = new Ext.UdpLoggerOptions(); testLog.WriteLine($"UDP options: {opts.IPEndPoint.ToString()}"); using (_receiver = new UdpReceiver()) { _receiver.Start(opts); // Add options to provider before create logger _provider = new Ext.UdpLoggerProvider(opts); var logger = _provider.CreateLogger("test") as Ext.UdpLogger; // Log some messages logger.Log(LogLevel.Debug, DEFAULT_EVENTID, DEFAULT_STATE, DEFAULT_EXCEPTION, setStringFormatter); logger.Log(LogLevel.Debug, DEFAULT_EVENTID, NULL_STATE, DEFAULT_EXCEPTION, setStringFormatter); logger.Log(LogLevel.Debug, DEFAULT_EVENTID, DEFAULT_STATE, NULL_EXCEPTION, setStringFormatter); // LogLevel None results is no log logger.Log(LogLevel.None, DEFAULT_EVENTID, DEFAULT_STATE, NULL_EXCEPTION, setStringFormatter); // Brief wait & stop listener System.Threading.Thread.Sleep(100); _receiver.Stop(); // NOTE: RetrieveMessages returns a _consuming_ enumerator, so it can only be used once. int msgCount = 0; foreach (var msg in _receiver.RetrieveMessages()) { ++msgCount; } msgCount.Should().Be(3); } }