/// <inheritdoc /> public StackTraceData Normalize() { string normalizedStackTrace = NormalizationUtils.NormalizeXmlText(stackTrace); if (ReferenceEquals(stackTrace, normalizedStackTrace)) { return(this); } return(new StackTraceData(normalizedStackTrace)); }
/// <inheritdoc /> public ExceptionData Normalize() { string normalizedType = NormalizationUtils.NormalizeName(type); string normalizedMessage = NormalizationUtils.NormalizeXmlText(message); StackTraceData normalizedStackTrace = stackTrace.Normalize(); PropertySet normalizedProperties = NormalizationUtils.NormalizeCollection <PropertySet, KeyValuePair <string, string> >(properties, () => new PropertySet(), x => new KeyValuePair <string, string>(NormalizationUtils.NormalizeName(x.Key), NormalizationUtils.NormalizeXmlText(x.Value)), (x, y) => x.Key == y.Key && x.Value == y.Value); ExceptionData normalizedInnerException = innerException != null?innerException.Normalize() : null; if (ReferenceEquals(type, normalizedType) && ReferenceEquals(message, normalizedMessage) && ReferenceEquals(stackTrace, normalizedStackTrace) && ReferenceEquals(properties, normalizedProperties) && ReferenceEquals(innerException, normalizedInnerException)) { return(this); } return(new ExceptionData(normalizedType, normalizedMessage, normalizedStackTrace, normalizedProperties, normalizedInnerException)); }
private void Handle(LogSeverity severity, string message, ExceptionData exceptionData, bool log) { message = NormalizationUtils.NormalizeXmlText(message); if (exceptionData != null) { exceptionData = exceptionData.Normalize(); } if (log) { inner.Log(severity, message, exceptionData); } // Note: We avoid taking any locks here because it would be too easy to end up // in a deadlock between logging and reporting code. Instead we compensate in // the listener by dropping the log message if the listener has been disposed. Listener currentListener = listener; if (currentListener != null) { listener.RecordLogEntry(severity, message, exceptionData); } }
public void NormalizeXmlText_WhenTextIsNotNormalized_ReturnsNormalizedInstance(string text, string normalizedText) { Assert.AreEqual(normalizedText, NormalizationUtils.NormalizeXmlText(text)); }
public void NormalizeXmlText_WhenTextIsAlreadyNormalized_ReturnsTheSameInstance(string text) { Assert.AreSame(text, NormalizationUtils.NormalizeXmlText(text)); }
public void NormalizeXmlText_WhenTextIsEmpty_ReturnsEmpty() { Assert.IsEmpty(NormalizationUtils.NormalizeXmlText("")); }
public void NormalizeXmlText_WhenTextIsNull_ReturnsNull() { Assert.IsNull(NormalizationUtils.NormalizeXmlText(null)); }
/// <inheritdoc /> public TestOutcome Normalize() { return(new TestOutcome(status, NormalizationUtils.NormalizeXmlText(category))); }
/// <summary> /// Normalizes markup text. /// </summary> /// <param name="text">The text, or null if none.</param> /// <returns>The normalized text, or null if none. May be the same instance if <paramref name="text"/> /// was already normalized.</returns> public static string NormalizeText(string text) { return(NormalizationUtils.NormalizeXmlText(text)); }
/// <summary> /// Normalizes a metadata value. /// </summary> /// <param name="metadataValue">The metadata value, or null if none.</param> /// <returns>The normalized metadata value, or null if none. May be the same instance if <paramref name="metadataValue"/> /// was already normalized.</returns> public static string NormalizeMetadataValue(string metadataValue) { return(NormalizationUtils.NormalizeXmlText(metadataValue)); }