Beispiel #1
0
        public void GetUpdatedPackages_OnePackageReferencedWithConstraintAndUpdatesAvailable_LatestVersionReturnedBasedOnConstraint()
        {
            AddPackageReference("Test", "1.0");
            FakePackage package = AddPackageToSourceRepository("Test", "2.0");

            FakePackage [] expectedPackages = new [] {
                package
            };
            AddPackageToSourceRepository("Test", "3.0");
            var versionSpec = new VersionSpec();

            versionSpec.MinVersion     = new SemanticVersion("1.0");
            versionSpec.IsMinInclusive = true;
            versionSpec.MaxVersion     = new SemanticVersion("2.0");
            versionSpec.IsMaxInclusive = true;
            var constraintProvider = new DefaultConstraintProvider();

            constraintProvider.AddConstraint("Test", versionSpec);
            project.ConstraintProvider = constraintProvider;
            var repository = new FakePackageRepository();

            repository.FakePackages = sourceRepositoryPackages;
            CreateUpdatedPackages(repository);

            IEnumerable <IPackage> packages = updatedPackages.GetUpdatedPackages();

            PackageCollectionAssert.AreEqual(expectedPackages, packages);
        }
        public void ReadPackages_TwoPackagesInSourceRepositoryAndTwoNewerPackageVersionAvailableAndProjectHasConstraint_NewerPackageVersionThatMeetsConstraintIsDisplayed()
        {
            CreateViewModel();
            var versionSpec = new VersionSpec();

            versionSpec.MinVersion     = new SemanticVersion("1.0");
            versionSpec.IsMinInclusive = true;
            versionSpec.MaxVersion     = new SemanticVersion("2.0");
            versionSpec.IsMaxInclusive = true;
            var constraintProvider = new DefaultConstraintProvider();

            constraintProvider.AddConstraint("Test", versionSpec);
            solution.FakeProjectToReturnFromGetProject.ConstraintProvider = constraintProvider;
            AddPackageToLocalRepository("Test", "1.0.0.0");
            AddPackageToActiveRepository("Test", "1.0.0.0");
            FakePackage expectedPackage = AddPackageToActiveRepository("Test", "2.0.0.0");

            AddPackageToActiveRepository("Test", "3.0.0.0");

            viewModel.ReadPackages();
            CompleteReadPackagesTask();

            var expectedPackages = new FakePackage[] {
                expectedPackage
            };

            PackageCollectionAssert.AreEqual(expectedPackages, viewModel.PackageViewModels);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PackageSession"/> class.
        /// </summary>
        public PackageSession(Package package)
        {
            constraintProvider.AddConstraint(PackageStore.Instance.DefaultPackageName, new VersionSpec(PackageStore.Instance.DefaultPackageVersion.ToSemanticVersion()));

            packages                    = new PackageCollection();
            packagesCopy                = new PackageCollection();
            assemblyContainer           = new AssemblyContainer();
            packages.CollectionChanged += PackagesCollectionChanged;
            if (package != null)
            {
                Packages.Add(package);
            }
        }
        public void Execute_PackageHasConstraint_LatestPackageIsNotUpdatedButPackageWithHighestVersionThatMatchesConstraint()
        {
            CreateSolution();
            var constraintProvider = new DefaultConstraintProvider();
            var versionSpec        = new VersionSpec();

            versionSpec.MinVersion     = new SemanticVersion("1.0");
            versionSpec.IsMinInclusive = true;
            versionSpec.IsMaxInclusive = true;
            versionSpec.MaxVersion     = new SemanticVersion("2.0");
            constraintProvider.AddConstraint("MyPackage", versionSpec);
            fakeProject.ConstraintProvider = constraintProvider;
            fakeProject.AddFakePackageToSourceRepository("MyPackage", "1.0");
            FakePackage packageVersion2 = fakeProject.AddFakePackageToSourceRepository("MyPackage", "2.0");

            fakeProject.AddFakePackageToSourceRepository("MyPackage", "3.0");
            fakeProject.FakePackages.Add(new FakePackage("MyPackage", "1.0"));
            action.PackageId = "MyPackage";

            action.Execute();

            Assert.AreEqual(packageVersion2, fakeProject.PackagePassedToUpdatePackage);
        }
 public void AddConstraint(string packageId, IVersionSpec versionSpec)
 {
     constraintProvider.AddConstraint(packageId, versionSpec);
 }