private static void VerifyDependenciesNode(SolutionExplorerItemTestExtension actualDependencies, Node[] nodes) { var expectDependencies = new Node("Dependencies", KnownMonikers.ReferenceGroup) { Children = new List <Node>(nodes) }; var expectOutput = new StringBuilder(); var actualOutput = new StringBuilder(); var same = true; VerifyNode(expectDependencies, actualDependencies); if (!same) { Assert.Fail($"Incorrect Dependencies tree.\n\nExpected:\n\n{expectOutput}\nActual:\n\n{actualOutput}"); } return; void VerifyNode(Node?expect, SolutionExplorerItemTestExtension?actual, int depth = 0) { Assert.IsTrue(expect != null || actual != null); var thisSame = true; if (actual != null && expect?.Text != null && expect.Text != actual.Name) { same = false; thisSame = false; } if (actual != null && expect?.Icon != null && !AssertExtensions.AreEqual(expect.Icon.Value, actual.ExpandedIconMoniker)) { same = false; thisSame = false; } var actualIcon = actual?.ExpandedIconMoniker == null ? "null" : ImageMonikerDebuggerDisplay.FromImageMoniker(actual.ExpandedIconMoniker.Value.ToImageMoniker()); if (expect != null) { expectOutput .Append(' ', depth * 4) .Append(expect.Text ?? actual !.Name) .Append(' ') .AppendLine(expect.Icon != null ? ImageMonikerDebuggerDisplay.FromImageMoniker(expect.Icon.Value) : actualIcon); } if (actual != null) { actualOutput .Append(' ', depth * 4) .Append(actual.Name) .Append(' ') .Append(actualIcon) .AppendLine(thisSame ? "" : " 🐛"); } if (expect?.Children != null) { if (actual?.IsExpanded == false && expect.Children != null && expect.Children.Count != 0) { actual.Expand(); } var actualChildren = actual?.Items.ToList() ?? new List <SolutionExplorerItemTestExtension>(); if (actualChildren.Count != expect.Children !.Count) { same = false; } var max = Math.Max(actualChildren.Count, expect.Children.Count); for (int i = 0; i < max; i++) { var expectChild = expect.Children.Count > i ? expect.Children[i] : null; var actualChild = actualChildren.Count > i ? actualChildren[i] : null; VerifyNode( expectChild, actualChild, depth + 1); } } } }
static string S(ImageMoniker a) => ImageMonikerDebuggerDisplay.FromImageMoniker(a);