public void Log_ExceptionInFormattedString_DisplaysExceptionMessage() { var name = nameof(GH258) + "A"; var target = NLogHelper.AssignMemoryTarget(name, @"${message}"); ILogManager logManager = NLogManager.Instance; var logger = logManager.GetLogger(name); logger.Debug("Message: {0} {1}", new NullReferenceException(), target.Name); var expected = $"Message: {new NullReferenceException()} {target.Name}"; var actual = target.Logs[0]; Assert.Equal(expected, actual); }
public void Log_ExceptionNotInFormattedString_ExceptionLoggedNotIncludedInMessage() { var name = nameof(GH258) + "B"; LogManager.SetImplementation(NLogManager.Instance); var target = NLogHelper.AssignMemoryTarget(name, @"${exception} ${message}"); var logger = LogManager.GetLogger(name); logger.Debug("Message but no exception", new NullReferenceException()); var expected = $"{new NullReferenceException().Message} Message but no exception"; var actual = target.Logs[0]; Assert.Equal(expected, actual); }
public void Send_FromDicomClient_DoesNotDeadlock() { LogManager.SetImplementation(NLogManager.Instance); var target = NLogHelper.AssignMemoryTarget( "Dicom.Network", @"${message}", NLog.LogLevel.Trace); var port = Ports.GetNext(); using (DicomServer.Create <DicomCEchoProvider>(port)) { var client = new DicomClient(); for (var i = 0; i < 10; i++) { client.AddRequest(new DicomCEchoRequest()); } client.Send("127.0.0.1", port, false, "SCU", "ANY-SCP"); Assert.True(target.Logs.Count > 0); } }