コード例 #1
0
 private string PrintTree(ExpectedTransactionTraceSegment expected, int depth, StringBuilder sb)
 {
     sb.AppendLine();
     for (int i = 0; i < depth; ++i)
     {
         sb.Append("    ");
     }
     sb.Append($"{expected.Name}, {expected.ClassName}, {expected.MethodName}");
     foreach (var segment in expected.ChildSegments)
     {
         PrintTree(segment, depth + 1, sb);
     }
     return(sb.ToString());
 }
コード例 #2
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);
        }