This class represents a tree node under the Updates tab
Наследование: SimpleTreeNode
Пример #1
0
        public void GetPackagesFindsUpdatesForFilteredSetOfPackages()
        {
            // Arrange
            var packageA = PackageUtility.CreatePackage("Foo", "1.0");
            var packageB = PackageUtility.CreatePackage("Qux", "1.0");
            var localRepository = new MockPackageRepository { packageA, packageB };
            IEnumerable<IPackage> actual = null;

            var sourceRepository = new Mock<IServiceBasedRepository>(MockBehavior.Strict);
            sourceRepository.Setup(s => s.GetUpdates(It.IsAny<IEnumerable<IPackage>>(), true, false, It.IsAny<IEnumerable<FrameworkName>>()))
                            .Returns(new[] { PackageUtility.CreatePackage("Foo", "1.1") })
                            .Callback((IEnumerable<IPackage> a, bool includePrerelease, bool includeAllVersions, IEnumerable<FrameworkName> frameworks) => actual = a)
                            .Verifiable();

            PackagesProviderBase provider = new MockPackagesProvider(new string[] { ".NETFramework,Version=3.0" });

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            var node = new UpdatesTreeNode(provider, "Mock", parentTreeNode, localRepository, sourceRepository.As<IPackageRepository>().Object);

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

            // Assert
            sourceRepository.Verify();
            Assert.Equal(new[] { packageA }, actual);
            AssertPackage(result.Single(), "Foo", "1.1");
        }
Пример #2
0
        public void GetPackagesDoesNotCacheResultsWhenOnClosedIsCalled(bool resetQueryBeforeRefresh)
        {
            // Arrange
            MockPackageRepository localRepository = new MockPackageRepository();
            localRepository.AddPackage(PackageUtility.CreatePackage("A", "1.0"));
            localRepository.AddPackage(PackageUtility.CreatePackage("B", "1.0"));

            MockPackageRepository sourceRepository = new MockPackageRepository();
            sourceRepository.AddPackage(PackageUtility.CreatePackage("A", "1.5-alpha"));


            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            var node = new UpdatesTreeNode(provider, "Mock", parentTreeNode, localRepository, sourceRepository);

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

            // Assert 1
            Assert.Equal(1, packages.Count);
            AssertPackage(packages[0], "A", "1.5-alpha");

            // Act 2
            node.OnClosed();

            // now we modify the source repository to test if the GetPackages() return the old results
            sourceRepository.AddPackage(PackageUtility.CreatePackage("B", "2.0-beta"));
            packages = node.GetPackages(searchTerm: null, allowPrereleaseVersions: true).ToList();
            packages.Sort(PackageComparer.Version);

            // Assert 2
            Assert.Equal(2, packages.Count);
            AssertPackage(packages[0], "A", "1.5-alpha");
            AssertPackage(packages[1], "B", "2.0-beta");
        }
Пример #3
0
        public void GetPackagesOnlyReturnPackagesCompatibleWithTheProjects()
        {
            // Arrange
            MockPackageRepository localRepository = new MockPackageRepository();
            localRepository.AddPackage(PackageUtility.CreatePackage("A", "1.0"));
            localRepository.AddPackage(PackageUtility.CreatePackage("B", "1.0"));

            MockPackageRepository sourceRepository = new MockPackageRepository();
            sourceRepository.AddPackage(PackageUtility.CreatePackage("A", "1.5"));
            sourceRepository.AddPackage(PackageUtility.CreatePackage("A", "1.9", assemblyReferences: new string[] { "lib\\sl4\\a.dll" }));
            sourceRepository.AddPackage(PackageUtility.CreatePackage("B", "2.0", assemblyReferences: new string[] { "lib\\net20\\b.dll" }));

            PackagesProviderBase provider = new MockPackagesProvider(new string[] { ".NETFramework,Version=3.0" });

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            var node = new UpdatesTreeNode(provider, "Mock", parentTreeNode, localRepository, sourceRepository);

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

            // Assert
            Assert.Equal(2, packages.Count);
            AssertPackage(packages[0], "A", "1.5");
            AssertPackage(packages[1], "B", "2.0");
        }
Пример #4
0
        public void GetPackagesCacheResultsWhenIncludePrereleaseIsFalse()
        {
            // Arrange
            MockPackageRepository localRepository = new MockPackageRepository();
            localRepository.AddPackage(PackageUtility.CreatePackage("A", "1.0"));
            localRepository.AddPackage(PackageUtility.CreatePackage("B", "1.0"));

            MockPackageRepository sourceRepository = new MockPackageRepository();
            sourceRepository.AddPackage(PackageUtility.CreatePackage("A", "1.5"));


            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            var node = new UpdatesTreeNode(provider, "Mock", parentTreeNode, localRepository, sourceRepository);

            // Act 1
            var packages = node.GetPackages(searchTerm: null, allowPrereleaseVersions: false).ToList();

            // Assert 1
            Assert.Equal(1, packages.Count);
            AssertPackage(packages[0], "A", "1.5");

            // Act 2

            // now we modify the source repository to test if the GetPackages() return the old results
            sourceRepository.AddPackage(PackageUtility.CreatePackage("B", "2.0"));
            packages = node.GetPackages(searchTerm: null, allowPrereleaseVersions: false).ToList();

            // Assert 2
            Assert.Equal(1, packages.Count);
            AssertPackage(packages[0], "A", "1.5");
        }