Concrete class to assist in testing the abstract PackagesTreeNodeBase
Inheritance: NuGet.Dialog.Providers.PackagesTreeNodeBase
Esempio n. 1
0
        public void GetPackagesDoNotCollapseVersionsIfBaseNodeDoesNotDoSo()
        {
            // Arrange
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock <IVsExtensionsTreeNode>().Object;
            MockTreeNode          baseTreeNode   = new MockTreeNode(
                parentTreeNode,
                provider,
                new[] {
                PackageUtility.CreatePackage("Azo", "1.0"),
                PackageUtility.CreatePackage("Azo", "2.0"),
                PackageUtility.CreatePackage("B", "3.0"),
                PackageUtility.CreatePackage("B", "4.0"),
                PackageUtility.CreatePackage("C", "5.0"),
            },
                collapseVersions: false
                );

            var node = new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, "Azo");

            // Act
            var packages = node.GetPackages(allowPrereleaseVersions: true).ToList();

            // Assert
            Assert.Equal(2, packages.Count);
            Assert.Equal("Azo", packages[0].Id);
            Assert.Equal(new SemanticVersion("1.0"), packages[0].Version);

            Assert.Equal("Azo", packages[1].Id);
            Assert.Equal(new SemanticVersion("2.0"), packages[1].Version);
        }
        public void GetPackagesDoNotCollapseVersionsIfBaseNodeDoesNotDoSo()
        {
            // Arrange
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            MockTreeNode baseTreeNode = new MockTreeNode(
                parentTreeNode,
                provider,
                new[] {
                    PackageUtility.CreatePackage("Azo", "1.0"),
                    PackageUtility.CreatePackage("Azo", "2.0"),
                    PackageUtility.CreatePackage("B", "3.0"),
                    PackageUtility.CreatePackage("B", "4.0"),
                    PackageUtility.CreatePackage("C", "5.0"),
                },
                collapseVersions: false
            );

            var node = new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, "Azo");

            // Act
            var packages = node.GetPackages().ToList();

            // Assert
            Assert.Equal(2, packages.Count);
            Assert.Equal("Azo", packages[0].Id);
            Assert.Equal(new SemanticVersion("1.0"), packages[0].Version);

            Assert.Equal("Azo", packages[1].Id);
            Assert.Equal(new SemanticVersion("2.0"), packages[1].Version);
        }
        public void GetPackagesReturnsUsesSearchTermPassedInConstructorForSearching()
        {
            // Arrange
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock <IVsExtensionsTreeNode>().Object;
            MockTreeNode          baseTreeNode   = new MockTreeNode(
                parentTreeNode,
                provider,
                new[] {
                PackageUtility.CreatePackage("TestPackage", "1.0"),
                PackageUtility.CreatePackage("TestPackage", "2.0"),
                PackageUtility.CreatePackage("Awesome", "1.0"),
                PackageUtility.CreatePackage("Awesome", "1.2"),
            },
                collapseVersions: false
                );

            var node = new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, "TestPackage");

            // Act
            var packages = node.GetPackages(searchTerm: "Foobar", allowPrereleaseVersions: true).ToList();

            // Assert
            Assert.Equal(2, packages.Count);
            Assert.Equal("TestPackage", packages[0].Id);
            Assert.Equal(new SemanticVersion("1.0"), packages[0].Version);

            Assert.Equal("TestPackage", packages[1].Id);
            Assert.Equal(new SemanticVersion("2.0"), packages[1].Version);
        }
Esempio n. 4
0
        private static PackagesSearchNode CreatePackagesSearchNode(string searchTerm, int numberOfPackages = 1)
        {
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock <IVsExtensionsTreeNode>().Object;
            MockTreeNode          baseTreeNode   = new MockTreeNode(parentTreeNode, provider, numberOfPackages);

            return(new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, searchTerm));
        }
Esempio n. 5
0
        public void SupportsPrereleasePackagesMatchBehaviorOfBaseNode(bool supportsPrereleasePackages)
        {
            // Arrange
            var baseNode = new MockTreeNode(
                new Mock <IVsExtensionsTreeNode>().Object,
                new MockPackagesProvider(),
                10,
                true,
                supportsPrereleasePackages);

            PackagesSearchNode node = CreatePackagesSearchNode("yyy", baseNode: baseNode);

            // Act & Assert
            Assert.Equal(supportsPrereleasePackages, node.SupportsPrereleasePackages);
        }
        public void SupportsPrereleasePackagesMatchBehaviorOfBaseNode(bool supportsPrereleasePackages)
        {
            // Arrange
            var baseNode = new MockTreeNode(
                new Mock<IVsExtensionsTreeNode>().Object, 
                new MockPackagesProvider(), 
                10, 
                true, 
                supportsPrereleasePackages);
            
            PackagesSearchNode node = CreatePackagesSearchNode("yyy", baseNode: baseNode);

            // Act & Assert
            Assert.Equal(supportsPrereleasePackages, node.SupportsPrereleasePackages);
        }
Esempio n. 7
0
        public void SearchNodeIsRemoveWhenDeselected()
        {
            // Arrange
            var parentTreeNode = new Mock <IVsExtensionsTreeNode>().Object;

            PackagesProviderBase provider = new MockPackagesProvider();
            var node = new MockTreeNode(parentTreeNode, provider, 1, true, true);

            provider.ExtensionsTree.Nodes.Add(node);
            provider.SelectedNode = node;

            var searchNode = (PackagesTreeNodeBase)provider.Search("hello");

            Assert.True(searchNode.IsSelected);
            Assert.True(searchNode.IsSearchResultsNode);

            // Act
            searchNode.OnClosed();

            // Arrange
            Assert.Equal(node, provider.SelectedNode);
            Assert.True(node.IsSelected);
        }
Esempio n. 8
0
        private static PackagesSearchNode CreatePackagesSearchNode(string searchTerm, int numberOfPackages = 1)
        {
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            MockTreeNode baseTreeNode = new MockTreeNode(parentTreeNode, provider, numberOfPackages);
            return new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, searchTerm);
        }
        public void SearchNodeIsRemoveWhenDeselected()
        {
            // Arrange
            var parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;

            PackagesProviderBase provider = new MockPackagesProvider();
            var node = new MockTreeNode(parentTreeNode, provider, 1, true, true);
            provider.ExtensionsTree.Nodes.Add(node);
            provider.SelectedNode = node;

            var searchNode = (PackagesTreeNodeBase)provider.Search("hello");
            Assert.True(searchNode.IsSelected);
            Assert.True(searchNode.IsSearchResultsNode);

            // Act 
            searchNode.OnClosed();

            // Arrange
            Assert.Equal(node, provider.SelectedNode);
            Assert.True(node.IsSelected);
        }
        private static PackagesSearchNode CreatePackagesSearchNode(string searchTerm, int numberOfPackages = 1, bool collapseVersions = true, PackagesTreeNodeBase baseNode = null)
        {
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            PackagesTreeNodeBase baseTreeNode;
            if (baseNode != null)
            {
                baseTreeNode = baseNode;
            }
            else
            {
                baseTreeNode = new MockTreeNode(parentTreeNode, provider, numberOfPackages, collapseVersions);
            }
            return new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, searchTerm);
        }
Esempio n. 11
0
        public void GetPackagesReturnsUsesSearchTermPassedInConstructorForSearching()
        {
            // Arrange
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            MockTreeNode baseTreeNode = new MockTreeNode(
                parentTreeNode,
                provider,
                new[] {
                    PackageUtility.CreatePackage("TestPackage", "1.0"),
                    PackageUtility.CreatePackage("TestPackage", "2.0"),
                    PackageUtility.CreatePackage("Awesome", "1.0"),
                    PackageUtility.CreatePackage("Awesome", "1.2"),
                },
                collapseVersions: false
            );

            var node = new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, "TestPackage");

            // Act
            var packages = node.GetPackages(searchTerm: "Foobar", allowPrereleaseVersions: true).ToList();

            // Assert
            Assert.Equal(2, packages.Count);
            Assert.Equal("TestPackage", packages[0].Id);
            Assert.Equal(new SemanticVersion("1.0"), packages[0].Version);

            Assert.Equal("TestPackage", packages[1].Id);
            Assert.Equal(new SemanticVersion("2.0"), packages[1].Version);
        }