GetPackages() public method

public GetPackages ( bool allowPrereleaseVersions ) : IQueryable
allowPrereleaseVersions bool
return IQueryable
コード例 #1
0
        public void GetPackagesDoNotReturnPrereleasePackagesIfToldSo()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            sourceRepository.AddPackage(PackageUtility.CreatePackage("Azo1", "2.0"));
            sourceRepository.AddPackage(PackageUtility.CreatePackage("Azo2", "3.0-alpha"));
            sourceRepository.AddPackage(PackageUtility.CreatePackage("B1", "2.0"));
            sourceRepository.AddPackage(PackageUtility.CreatePackage("B2", "4.0"));

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            PackagesProviderBase provider = new MockPackagesProvider();
            var baseNode = new SimpleTreeNode(provider, "Online", parentTreeNode, sourceRepository);

            var searchNode = new PackagesSearchNode(provider, parentTreeNode, baseNode, "Azo");

            // Act
            var packages = searchNode.GetPackages(allowPrereleaseVersions: false).ToList();

            // Assert
            Assert.Equal(1, packages.Count);
            Assert.Equal("Azo1", packages[0].Id);
            Assert.Equal(new SemanticVersion("2.0"), packages[0].Version);
        }
コード例 #2
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().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);
        }
コード例 #3
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);
        }