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);
    }
예제 #2
0
 public void Validate_expected_libyears(DateTimeOffset releaseDateCurrentVersion,
                                        DateTimeOffset releaseDateLatestVersion, double expectedLibYear,
                                        int precision) => Assert.Equal(expectedLibYear,
                                                                       LibYear.GivenReleaseDates(releaseDateCurrentVersion, releaseDateLatestVersion).AsDecimalNumber(precision));