コード例 #1
0
ファイル: StackTraceData.cs プロジェクト: citizenmatt/gallio
        /// <inheritdoc />
        public StackTraceData Normalize()
        {
            string normalizedStackTrace = NormalizationUtils.NormalizeXmlText(stackTrace);

            if (ReferenceEquals(stackTrace, normalizedStackTrace))
            {
                return(this);
            }

            return(new StackTraceData(normalizedStackTrace));
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
            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);
                }
            }
コード例 #4
0
 public void NormalizeXmlText_WhenTextIsNotNormalized_ReturnsNormalizedInstance(string text,
                                                                                string normalizedText)
 {
     Assert.AreEqual(normalizedText, NormalizationUtils.NormalizeXmlText(text));
 }
コード例 #5
0
 public void NormalizeXmlText_WhenTextIsAlreadyNormalized_ReturnsTheSameInstance(string text)
 {
     Assert.AreSame(text, NormalizationUtils.NormalizeXmlText(text));
 }
コード例 #6
0
 public void NormalizeXmlText_WhenTextIsEmpty_ReturnsEmpty()
 {
     Assert.IsEmpty(NormalizationUtils.NormalizeXmlText(""));
 }
コード例 #7
0
 public void NormalizeXmlText_WhenTextIsNull_ReturnsNull()
 {
     Assert.IsNull(NormalizationUtils.NormalizeXmlText(null));
 }
コード例 #8
0
 /// <inheritdoc />
 public TestOutcome Normalize()
 {
     return(new TestOutcome(status, NormalizationUtils.NormalizeXmlText(category)));
 }
コード例 #9
0
 /// <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));
 }
コード例 #10
0
 /// <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));
 }