/// <summary>
        /// Verifies that the solution's first "Dependencies" node has a structure that
        /// matches <paramref name="nodes"/>.
        /// </summary>
        /// <param name="nodes">The expected structure for the Dependencies node.</param>
        protected void VerifyDependenciesNode(params Node[] nodes)
        {
            using (Scope.Enter("Verify dependency nodes"))
            {
                SolutionExplorerItemTestExtension actualDependencies = VisualStudio.ObjectModel.Solution.SolutionExplorer.FindItemRecursive("Dependencies", expandToFind: true);

                VerifyDependenciesNode(actualDependencies, nodes);
            }
        }
示例#2
0
        private InstallDialogTestExtension OpenWizardFromSolutionExplorerItem(string nodeName)
        {
            SolutionExplorerItemTestExtension solutionExplorerItemTestExtension = SolutionExplorer.FindItemRecursive(nodeName);

            solutionExplorerItemTestExtension.Select();

            InstallDialogTestService   installDialogTestService    = VisualStudio.Get <InstallDialogTestService>();
            InstallDialogTestExtension installDialogTestExtenstion = installDialogTestService.OpenDialog();

            return(installDialogTestExtenstion);
        }
示例#3
0
        private void SetLibraryAndClickInstall(string nodeName, string library)
        {
            SolutionExplorerItemTestExtension solutionExplorerItemTestExtension = SolutionExplorer.FindItemRecursive(nodeName);
            solutionExplorerItemTestExtension.Select();

            InstallDialogTestService installDialogTestService = VisualStudio.Get<InstallDialogTestService>();
            InstallDialogTestExtension installDialogTestExtenstion = installDialogTestService.OpenDialog();

            installDialogTestExtenstion.SetLibrary(library);
            installDialogTestExtenstion.ClickInstall();
        }
示例#4
0
        private void CleanClientSideLibraries()
        {
            Guid guid      = Guid.Parse("44ee7bda-abda-486e-a5fe-4dd3f4cefac1");
            uint commandId = 0x0200;
            SolutionExplorerItemTestExtension libmanConfigNode = SolutionExplorer.FindItemRecursive(LibManManifestFile);

            if (libmanConfigNode != null)
            {
                libmanConfigNode.Select();

                WaitFor.IsTrue(() =>
                {
                    CommandQueryResult queryResult = VisualStudio.ObjectModel.Commanding.QueryStatusCommand(guid, commandId);
                    return(queryResult.IsEnabled);
                }, TimeSpan.FromMilliseconds(40000), TimeSpan.FromMilliseconds(500));

                VisualStudio.ObjectModel.Commanding.ExecuteCommand(guid, commandId, null);
            }
        }
        private void VerifyDependenciesNode(SolutionExplorerItemTestExtension actualDependencies, Node[] nodes)
        {
            var expectDependencies = new Node("Dependencies", ManagedImageMonikers.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"
                    : ManagedImageMonikers.ImageMonikerDebugDisplay(actual.ExpandedIconMoniker.Value.ToImageMoniker());

                if (expect != null)
                {
                    expectOutput
                    .Append(' ', depth * 4)
                    .Append(expect.Text ?? actual !.Name)
                    .Append(' ')
                    .Append(expect.Icon != null
                            ? ManagedImageMonikers.ImageMonikerDebugDisplay(expect.Icon.Value)
                            : actualIcon)
                    .AppendLine();
                }

                if (actual != null)
                {
                    actualOutput
                    .Append(' ', depth * 4)
                    .Append(actual.Name)
                    .Append(' ')
                    .Append(actualIcon)
                    .Append(thisSame ? "" : " 🐛")
                    .AppendLine();
                }

                if (expect?.Children != null)
                {
                    if (actual != null && !actual.IsExpanded && 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);
                    }
                }
            }
        }