public void Verify_it_can_create_a_json_object() { // File was shortened to only show relevant information for this test var fileContents = @"{ ""components"": [ { ""purl"": ""pkg:nuget/org.corgibytes.calculatron/[email protected]"" }, { ""purl"": ""pkg:nuget/org.corgibytes.flyswatter/[email protected]"" }, { ""purl"": ""pkg:composer/org.corgibytes.tea/[email protected]"" } ] }"; _fileReaderService.FeedJson(fileContents); var expectedPackageUrls = new List <PackageURL> { new("pkg:nuget/org.corgibytes.calculatron/[email protected]"), new("pkg:nuget/org.corgibytes.flyswatter/[email protected]"), new("pkg:composer/org.corgibytes.tea/[email protected]") }; Assert.Equivalent(expectedPackageUrls, _readCycloneDxFile.AsPackageUrls("This/is/a/filepath")); }
public IList <PackageLibYear> AsList(string filePath, int precision = 2) { var packageUrls = _readFile.AsPackageUrls(filePath); var libYearList = new List <PackageLibYear>(); foreach (var currentlyInstalled in packageUrls) { try { var latestVersion = _repository.GetLatestVersion(currentlyInstalled); var releaseDatePackageCurrentlyInstalled = _repository.GetReleaseDate(currentlyInstalled); var releaseDatePackageLatestAvailable = _repository.GetReleaseDate(latestVersion); libYearList.Add(new PackageLibYear( releaseDatePackageCurrentlyInstalled, currentlyInstalled, releaseDatePackageLatestAvailable, latestVersion, LibYear.GivenReleaseDates(releaseDatePackageCurrentlyInstalled, releaseDatePackageLatestAvailable) .AsDecimalNumber(precision) )); } catch (Exception exception) { libYearList.Add(new PackageLibYear( currentlyInstalled, exception.Message )); } } return(libYearList); }