public void GetRemotePackagesTest()
        {
            // Arrange
            var siteRoot         = "x:\\";
            var localRepository  = new MockPackageRepository();
            var sourceRepository = new MockServiceBasePackageRepository();
            var projectSystem    = new WebProjectSystem(siteRoot);
            var pathResolver     = new DefaultPackagePathResolver(projectSystem);
            var projectManager   = new ProjectManager(sourceRepository, pathResolver, projectSystem, localRepository);

            var net40 = new FrameworkName(".NETFramework", new Version("4.0.0.0"));
            var net45 = new FrameworkName(".NETFramework", new Version("4.5.0.0"));

            IPackage packageA = PackageFactory.Create("A", new Version("1.0"), null, new FrameworkName[] { net40 });
            IPackage packageB = PackageFactory.Create("B", new Version("1.0"), null, new FrameworkName[] { net45 });
            IPackage packageC = PackageFactory.Create("C", new Version("1.0"));

            sourceRepository.AddPackage(packageA);
            sourceRepository.AddPackage(packageB);
            sourceRepository.AddPackage(packageC);

            // NOTE THAT target framework used by WebProjectManager would be .NETFramework, Version=4.0.0.0
            var webProjectManager = new WebProjectManager(projectManager, siteRoot);

            // Act
            var packages = webProjectManager.GetRemotePackages(null, false).ToList();

            // Assert
            Assert.Equal(2, packages.Count);
            Assert.Equal(packageA, packages[0]);
            Assert.Equal(packageC, packages[1]);
        }
        public void GetPackagesReturnsUpdatesWhenThereAreMultipleVersionsOfTheSamePackageId()
        {
            // Arrange
            var localRepository  = new MockPackageRepository();
            var sourceRepository = new MockServiceBasePackageRepository();

            UpdatesTreeNode node = CreateUpdatesTreeNode(localRepository, sourceRepository, includePrerelease: false);

            localRepository.AddPackage(PackageUtility.CreatePackage("A", "9.0-rtm"));
            localRepository.AddPackage(PackageUtility.CreatePackage("B", "1.0"));
            localRepository.AddPackage(PackageUtility.CreatePackage("A", "9.0"));
            localRepository.AddPackage(PackageUtility.CreatePackage("A", "10.0"));

            sourceRepository.AddPackage(PackageUtility.CreatePackage("A", "9.5"));
            sourceRepository.AddPackage(PackageUtility.CreatePackage("B", "4.0-beta"));
            sourceRepository.AddPackage(PackageUtility.CreatePackage("C", "1.2.3.4-alpha"));

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

            // Assert
            Assert.Equal(2, packages.Count);
            AssertPackage(packages[0], "A", "9.5");
            AssertPackage(packages[1], "B", "4.0-beta");
        }
Esempio n. 3
0
        public void GetRemotePackagesTest()
        {
            // Arrange
            var siteRoot = "x:\\";
            var localRepository = new MockPackageRepository();
            var sourceRepository = new MockServiceBasePackageRepository();
            var projectSystem = new WebProjectSystem(siteRoot);
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(sourceRepository, pathResolver, projectSystem, localRepository);

            var net40 = new FrameworkName(".NETFramework", new Version("4.0.0.0"));
            var net45 = new FrameworkName(".NETFramework", new Version("4.5.0.0"));

            IPackage packageA = PackageFactory.Create("A", new Version("1.0"), null, new FrameworkName[]{ net40 });
            IPackage packageB = PackageFactory.Create("B", new Version("1.0"), null, new FrameworkName[]{ net45 });
            IPackage packageC = PackageFactory.Create("C", new Version("1.0"));

            sourceRepository.AddPackage(packageA);
            sourceRepository.AddPackage(packageB);
            sourceRepository.AddPackage(packageC);

            // NOTE THAT target framework used by WebProjectManager would be .NETFramework, Version=4.0.0.0
            var webProjectManager = new WebProjectManager(projectManager, siteRoot);

            // Act
            var packages = webProjectManager.GetRemotePackages(null, false).ToList();

            // Assert
            Assert.Equal(2, packages.Count);
            Assert.Equal(packageA, packages[0]);
            Assert.Equal(packageC, packages[1]);
        }