public void FindDependencyPicksLowestMajorAndMinorVersionButHighestBuildAndRevision() { // Arrange var repository = new MockPackageRepository() { PackageUtility.CreatePackage("B", "2.0"), PackageUtility.CreatePackage("B", "1.0"), PackageUtility.CreatePackage("B", "1.0.1"), PackageUtility.CreatePackage("B", "1.0.9"), PackageUtility.CreatePackage("B", "1.1") }; // B >= 1.0 PackageDependency dependency1 = PackageDependency.CreateDependency("B", "1.0"); // B >= 1.0.0 PackageDependency dependency2 = PackageDependency.CreateDependency("B", "1.0.0"); // B >= 1.0.0.0 PackageDependency dependency3 = PackageDependency.CreateDependency("B", "1.0.0.0"); // B = 1.0 PackageDependency dependency4 = PackageDependency.CreateDependency("B", "[1.0]"); // B >= 1.0.0 && <= 1.0.8 PackageDependency dependency5 = PackageDependency.CreateDependency("B", "[1.0.0, 1.0.8]"); // Act IPackage package1 = repository.FindDependency(dependency1); IPackage package2 = repository.FindDependency(dependency2); IPackage package3 = repository.FindDependency(dependency3); IPackage package4 = repository.FindDependency(dependency4); IPackage package5 = repository.FindDependency(dependency5); // Assert Assert.AreEqual("B", package1.Id); Assert.AreEqual(new Version("1.0.9"), package1.Version); Assert.AreEqual("B", package2.Id); Assert.AreEqual(new Version("1.0.9"), package2.Version); Assert.AreEqual("B", package3.Id); Assert.AreEqual(new Version("1.0.9"), package3.Version); Assert.AreEqual("B", package4.Id); Assert.AreEqual(new Version("1.0"), package4.Version); Assert.AreEqual("B", package5.Id); Assert.AreEqual(new Version("1.0.1"), package5.Version); }
public void FindDependencyPicksHighestVersionIfNotSpecified() { // Arrange var repository = new MockPackageRepository() { PackageUtility.CreatePackage("B", "2.0"), PackageUtility.CreatePackage("B", "1.0"), PackageUtility.CreatePackage("B", "1.0.1"), PackageUtility.CreatePackage("B", "1.0.9"), PackageUtility.CreatePackage("B", "1.1") }; var dependency = new PackageDependency("B"); // Act IPackage package = repository.FindDependency(dependency); // Assert Assert.AreEqual("B", package.Id); Assert.AreEqual(new Version("2.0"), package.Version); }