public void GetPackageReferencesReturnsNullForNonExistentId()
        {
            // Arrange
            var config     = @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
  <package id=""A"" version=""1.3.4"" />
  <package id=""A"" version=""2.5-beta"" />
  <package id=""B"" version=""1.0"" />
  <package id=""C"" version=""2.1.4"" />
</packages>";
            var fileSystem = new MockFileSystem();

            fileSystem.AddFile("packages.config", config);
            var packageReferenceFile = new PackageReferenceFile(fileSystem, "packages.config");

            // Act
            PackageName packageName = packageReferenceFile.FindEntryWithLatestVersionById("nonexistentId");

            // Assert
            Assert.Null(packageName);
        }
        public void GetPackageReferencesFindTheOnlyVersionAsLatestVersion()
        {
            // Arrange
            var config     = @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
  <package id=""A"" version=""1.3.4"" />
  <package id=""A"" version=""2.5-beta"" />
  <package id=""B"" version=""1.0"" />
  <package id=""C"" version=""2.1.4"" />
</packages>";
            var fileSystem = new MockFileSystem();

            fileSystem.AddFile("packages.config", config);
            var packageReferenceFile = new PackageReferenceFile(fileSystem, "packages.config");

            // Act
            PackageName packageName = packageReferenceFile.FindEntryWithLatestVersionById("B");

            // Assert
            Assert.NotNull(packageName);
            Assert.Equal("B", packageName.Id);
            Assert.Equal(new SemanticVersion("1.0"), packageName.Version);
        }
        public void GetPackageReferencesReturnsNullForNonExistentId()
        {
            // Arrange
            var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
  <package id=""A"" version=""1.3.4"" />
  <package id=""A"" version=""2.5-beta"" />
  <package id=""B"" version=""1.0"" />
  <package id=""C"" version=""2.1.4"" />
</packages>";
            var fileSystem = new MockFileSystem();
            fileSystem.AddFile("packages.config", config);
            var packageReferenceFile = new PackageReferenceFile(fileSystem, "packages.config");

            // Act
            PackageName packageName = packageReferenceFile.FindEntryWithLatestVersionById("nonexistentId");

            // Assert
            Assert.Null(packageName);
        }
        public void GetPackageReferencesFindTheOnlyVersionAsLatestVersion()
        {
            // Arrange
            var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
  <package id=""A"" version=""1.3.4"" />
  <package id=""A"" version=""2.5-beta"" />
  <package id=""B"" version=""1.0"" />
  <package id=""C"" version=""2.1.4"" />
</packages>";
            var fileSystem = new MockFileSystem();
            fileSystem.AddFile("packages.config", config);
            var packageReferenceFile = new PackageReferenceFile(fileSystem, "packages.config");

            // Act
            PackageName packageName = packageReferenceFile.FindEntryWithLatestVersionById("B");

            // Assert
            Assert.NotNull(packageName);
            Assert.Equal("B", packageName.Id);
            Assert.Equal(new SemanticVersion("1.0"), packageName.Version);
        }