public static TransactionTraceSegment TryFindSegment(this TransactionTraceSegment segment, string name, string parameterKey, string parameterValue)
        {
            Contract.Assert(segment != null);
            Contract.Assert(name != null);
            Contract.Assert(parameterKey != null);
            Contract.Assert(parameterValue != null);

            if (segment.Name == name &&
                segment.Parameters != null &&
                segment.Parameters.Contains(new KeyValuePair <string, object>(parameterKey, parameterValue)))
            {
                return(segment);
            }

            if (segment.ChildSegments == null)
            {
                return(null);
            }

            return(segment
                   .ChildSegments
                   .Select(childSegment => childSegment.TryFindSegment(name, parameterKey, parameterValue))
                   .Where(foundSegment => foundSegment != null)
                   .FirstOrDefault());
        }
 public TransactionTrace(DateTime timestamp, object unknown1, object unknown2, TransactionTraceSegment rootSegment, TransactionTraceAttributes attributes)
 {
     Timestamp   = timestamp;
     Unknown1    = unknown1;
     RootSegment = rootSegment;
     Unknown2    = unknown2;
     Attributes  = attributes;
 }
Beispiel #3
0
 private string PrintTree(TransactionTraceSegment actual, int depth, StringBuilder sb)
 {
     sb.AppendLine();
     for (int i = 0; i < depth; ++i)
     {
         sb.Append("    ");
     }
     sb.Append($"{actual.Name}, {actual.ClassName}, {actual.MethodName}");
     foreach (var segment in actual.ChildSegments)
     {
         PrintTree(segment, depth + 1, sb);
     }
     return(sb.ToString());
 }
Beispiel #4
0
        private string PrintTree(TransactionTraceSegment actual)
        {
            var sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine("Expected:");
            sb.Append($"{Name}, {ClassName}, {MethodName}");
            foreach (var segment in ChildSegments)
            {
                PrintTree(segment, 1, sb);
            }
            sb.AppendLine();
            sb.AppendLine("Actual:");
            sb.Append($"{actual.Name}, {actual.ClassName}, {actual.MethodName}");
            foreach (var segment in actual.ChildSegments)
            {
                PrintTree(segment, 1, sb);
            }
            return(sb.ToString());
        }
        public static TransactionTraceSegment TryFindSegment(this TransactionTraceSegment segment, string name)
        {
            Contract.Assert(segment != null);
            Contract.Assert(name != null);

            if (segment.Name == name)
            {
                return(segment);
            }

            if (segment.ChildSegments == null)
            {
                return(null);
            }

            return(segment
                   .ChildSegments
                   .Select(childSegment => childSegment.TryFindSegment(name))
                   .Where(foundSegment => foundSegment != null)
                   .FirstOrDefault());
        }
Beispiel #6
0
        private bool CompareToActualTransactionTrace(ExpectedTransactionTraceSegment expected, TransactionTraceSegment actual)
        {
            var expectedChildSegments = expected.ChildSegments.ToArray();
            var actualChildSegments   = actual.ChildSegments.ToArray();

            if (expectedChildSegments.Length != actualChildSegments.Length)
            {
                return(false);
            }

            var structureMatches = true;

            for (var i = 0; structureMatches && i < expectedChildSegments.Length; ++i)
            {
                if (expectedChildSegments[i].OrderedChild)
                {
                    structureMatches = CompareToActualTransactionTrace(expectedChildSegments[i], actualChildSegments[i]);
                }
                else
                {
                    var foundMatchingSubtree = false;
                    var isOrderedChild       = false;
                    for (var offset = i; !foundMatchingSubtree && !isOrderedChild && offset < expectedChildSegments.Length; ++offset)
                    {
                        isOrderedChild       = expectedChildSegments[offset].OrderedChild;
                        foundMatchingSubtree = CompareToActualTransactionTrace(expectedChildSegments[offset], actualChildSegments[i]);
                        if (foundMatchingSubtree)
                        {
                            var t = expectedChildSegments[i];
                            expectedChildSegments[i]      = expectedChildSegments[offset];
                            expectedChildSegments[offset] = t;
                        }
                    }

                    structureMatches = foundMatchingSubtree;
                }
            }

            return(structureMatches &&
                   expected.Name == actual.Name &&
                   expected.ClassName == actual.ClassName &&
                   expected.MethodName == actual.MethodName);
        }
Beispiel #7
0
        public TransactionTraceComparisonResult CompareToActualTransactionTrace(TransactionTraceSegment compare)
        {
            var equivalent = CompareToActualTransactionTrace(this, compare);

            return(new TransactionTraceComparisonResult(equivalent, PrintTree(compare)));
        }