public void TestRepositoryOrderingAffectsPriority() { var repository1 = new RepositoryArray(); var repository2 = new RepositoryArray(); var package1 = Helper.MockPackage("foo", "1.0"); var package2 = Helper.MockPackage("foo", "1.1"); var package3 = Helper.MockPackage("foo", "1.1"); var package4 = Helper.MockPackage("foo", "1.2"); repository1.AddPackage(package1); repository1.AddPackage(package2); repository2.AddPackage(package3); repository2.AddPackage(package4); pool.AddRepository(repository1); pool.AddRepository(repository2); var literals = new[] { package1.Id, package2.Id, package3.Id, package4.Id }; var expected = new[] { package2.Id }; var actual = policy.SelectPreferredPackages(pool, GetInstalledMap(), literals); CollectionAssert.AreEqual(expected, actual); pool = new Pool(Stabilities.Dev); pool.AddRepository(repository2); pool.AddRepository(repository1); expected = new[] { package4.Id }; actual = policy.SelectPreferredPackages(pool, GetInstalledMap(), literals); CollectionAssert.AreEqual(expected, actual); }
public void TestAddRepository() { repositoryOne.AddPackage(Helper.MockPackage("foo", "1.0")); Assert.AreEqual(1, repositoryComposite.Count); var repositoryOther = new RepositoryArray(); repositoryOther.AddPackage(Helper.MockPackage("bar", "1.0")); repositoryOther.AddPackage(Helper.MockPackage("bar", "2.0")); repositoryOther.AddPackage(Helper.MockPackage("bar", "3.0")); repositoryComposite.AddRepository(repositoryOther); Assert.AreEqual(4, repositoryComposite.Count); }
public void TestHasPackage() { var packageFoo = Helper.MockPackage("foo", "1"); var packageBar = Helper.MockPackage("bar", "2"); var repository = new RepositoryArray(); repository.AddPackage(packageFoo); repository.AddPackage(Helper.MockPackage("bar", "3")); Assert.IsTrue(repository.HasPackage(packageFoo)); Assert.IsFalse(repository.HasPackage(packageBar)); Assert.IsTrue(repository.HasPackage(Helper.MockPackage("bar", "3"))); }
public void TestRemovePackage() { var packageFoo = Helper.MockPackage("foo", "1"); var packageBar = Helper.MockPackage("bar", "2"); var repository = new RepositoryArray(); repository.AddPackage(packageFoo); repository.AddPackage(packageBar); Assert.AreEqual(2, repository.Count); repository.RemovePackage(packageFoo); Assert.AreEqual(1, repository.Count); CollectionAssert.AreEqual(new[] { packageBar }, repository.GetPackages()); }
public void TestAddPackage() { var repository = new RepositoryArray(); repository.AddPackage(Helper.MockPackage("foo", "1")); Assert.AreEqual(1, repository.Count); }
public void TestHasPackage() { repositoryOne.AddPackage(Helper.MockPackage("foo", "1.0")); repositoryTwo.AddPackage(Helper.MockPackage("bar", "1.0")); Assert.IsTrue(repositoryComposite.HasPackage(Helper.MockPackage("foo", "1.0"))); Assert.IsTrue(repositoryComposite.HasPackage(Helper.MockPackage("bar", "1.0"))); Assert.IsFalse(repositoryComposite.HasPackage(Helper.MockPackage("foo", "2.0"))); Assert.IsFalse(repositoryComposite.HasPackage(Helper.MockPackage("bar", "2.0"))); }
public void TestPreferReplacingPackageFromSameVendor() { // test default order. var fooReplaces = new[] { new Link("@vendor-foo/replacer", "@vendor-foo/package", new Constraint("=", "1.0"), "replaces"), }; var barReplaces = new[] { new Link("@vendor-bar/replacer", "@vendor-foo/package", new Constraint("=", "1.0"), "replaces"), }; var packageFoo = Helper.MockPackage("@vendor-foo/replacer", "1.0", null, fooReplaces); var packageBar = Helper.MockPackage("@vendor-bar/replacer", "1.0", null, barReplaces); repository.AddPackage(packageFoo); repository.AddPackage(packageBar); pool.AddRepository(repository); var literals = new[] { packageFoo.Id, packageBar.Id }; var expected = literals; var actual = policy.SelectPreferredPackages(pool, GetInstalledMap(), literals, "@vendor-foo/package"); CollectionAssert.AreEqual(expected, actual); // test with reversed order in repository packageFoo = Helper.MockPackage("@vendor-foo/replacer", "1.0", null, fooReplaces); packageBar = Helper.MockPackage("@vendor-bar/replacer", "1.0", null, barReplaces); var reversedRepository = new RepositoryArray(); reversedRepository.AddPackage(packageBar); reversedRepository.AddPackage(packageFoo); var devPool = new Pool(Stabilities.Dev); devPool.AddRepository(reversedRepository); actual = policy.SelectPreferredPackages(pool, GetInstalledMap(), literals, "@vendor-foo/package"); CollectionAssert.AreEqual(expected, actual); }
public void TestSearchWithPackageType() { var repository = new RepositoryArray(); repository.AddPackage(Helper.MockPackage("foo", "1", type: PackageType.Library)); repository.AddPackage(Helper.MockPackage("bar", "2", type: PackageType.Library)); repository.AddPackage(Helper.MockPackage("foobar", "3", type: PackageType.Plugin)); var searched = repository.Search("foo", SearchMode.Fulltext, PackageType.Library); Assert.AreEqual(1, searched.Length); Assert.AreEqual("foo", searched[0].GetName()); Assert.AreEqual(null, searched[0].GetDescription()); searched = repository.Search("bar", SearchMode.Fulltext, PackageType.Plugin); Assert.AreEqual(1, searched.Length); Assert.AreEqual("foobar", searched[0].GetName()); Assert.AreEqual(null, searched[0].GetDescription()); }
public void TestFindPackages() { var repository = new RepositoryArray(); repository.AddPackage(Helper.MockPackage("foo", "1")); repository.AddPackage(Helper.MockPackage("bar", "2")); repository.AddPackage(Helper.MockPackage("bar", "3")); var foo = repository.FindPackages("foo"); Assert.AreEqual(1, foo.Length); Assert.AreEqual("foo", foo[0].GetName()); var bar = repository.FindPackages("bar"); Assert.AreEqual(2, bar.Length); Assert.AreEqual("bar", bar[0].GetName()); Assert.AreEqual("2", bar[0].GetVersionPretty()); Assert.AreEqual("bar", bar[1].GetName()); Assert.AreEqual("3", bar[1].GetVersionPretty()); }
public void TestSearch() { var repository = new RepositoryArray(); repository.AddPackage(Helper.MockPackage("foo", "1")); repository.AddPackage(Helper.MockPackage("bar", "2")); var searched = repository.Search("foo", SearchMode.Fulltext); Assert.AreEqual(1, searched.Length); Assert.AreEqual("foo", searched[0].GetName()); Assert.AreEqual(null, searched[0].GetDescription()); searched = repository.Search("bar"); Assert.AreEqual(1, searched.Length); Assert.AreEqual("bar", searched[0].GetName()); Assert.AreEqual(null, searched[0].GetDescription()); searched = repository.Search("foobar"); Assert.AreEqual(0, searched.Length); }
public void TestSelectNewestOverThanInstalled() { var packageFoo = Helper.MockPackage("foo", "2.0"); var packageFooInstalled = Helper.MockPackage("foo", "1.0"); repository.AddPackage(packageFoo); repositoryInstalled.AddPackage(packageFooInstalled); pool.AddRepository(repositoryInstalled); pool.AddRepository(repository); var literals = new[] { packageFoo.Id, packageFooInstalled.Id }; var expected = new[] { packageFoo.Id }; var actual = policy.SelectPreferredPackages(pool, GetInstalledMap(), literals); CollectionAssert.AreEqual(expected, actual); }
public void TestSolverInstallSamePackageFromDifferentRepositories() { var repository1 = new RepositoryArray(); var repository2 = new RepositoryArray(); var packageFoo1 = Helper.MockPackage("foo", "1.0"); var packageFoo2 = Helper.MockPackage("foo", "1.0"); repository1.AddPackage(packageFoo1); repository2.AddPackage(packageFoo2); pool.AddRepository(repository1); pool.AddRepository(repository2); request.Install("foo"); AssertSolverResult((JobCommand.Install, packageFoo1)); }
public void TestAutomaticallyAddAliasedPackageButNotRemove() { var repository = new RepositoryArray(); var package = Helper.MockPackage("foo", "1"); var alias = Helper.MockPackageAlias(package, "2"); repository.AddPackage(alias); Assert.AreEqual(2, repository.Count); Assert.IsTrue(repository.HasPackage(Helper.MockPackage("foo", "1"))); Assert.IsTrue(repository.HasPackage(Helper.MockPackage("foo", "2"))); repository.RemovePackage(alias); Assert.AreEqual(1, repository.Count); Assert.IsTrue(repository.HasPackage(Helper.MockPackage("foo", "1"))); Assert.IsFalse(repository.HasPackage(Helper.MockPackage("foo", "2"))); }
public void TestSelectFirstRepository() { var repositoryOther = new RepositoryArray(); var packageFoo = Helper.MockPackage("foo", "1.0"); var packageFooImportant = Helper.MockPackage("foo", "1.0"); repository.AddPackage(packageFoo); repositoryOther.AddPackage(packageFooImportant); // The order of addition determines the priority. pool.AddRepository(repositoryInstalled); pool.AddRepository(repositoryOther); pool.AddRepository(repository); var literals = new[] { packageFoo.Id, packageFooImportant.Id }; var expected = new[] { packageFooImportant.Id }; var actual = policy.SelectPreferredPackages(pool, GetInstalledMap(), literals); CollectionAssert.AreEqual(expected, actual); }
public void TestSolverUninstallInstalledPackageIfNotInstall() { var packageFoo = Helper.MockPackage("foo", "1.0"); repositoryInstalled.AddPackage(packageFoo); RepositoryComplete(); AssertSolverResult((JobCommand.Uninstall, packageFoo)); }
public void TestSolverInstallSingle() { var packageFoo = Helper.MockPackage("foo", "1.0"); repository.AddPackage(packageFoo); RepositoryComplete(); request.Install("foo"); AssertSolverResult((JobCommand.Install, packageFoo)); }