Example #1
0
        public VersionLists(VersionListData data)
        {
            var allVersions = data
                              .VersionProperties
                              .Select(p => new VersionProperties(p.Key, p.Value))
                              .OrderBy(x => x.ParsedVersion)
                              .ToList();

            _versionProperties = new SortedDictionary <NuGetVersion, KeyValuePair <string, VersionPropertiesData> >();
            foreach (var version in allVersions)
            {
                _versionProperties.Add(version.ParsedVersion, KeyValuePair.Create(version.FullVersion, version.Data));
            }

            _versionLists = new Dictionary <SearchFilters, FilteredVersionList>();
            foreach (var pair in SearchFilterPredicates)
            {
                var searchFilter = pair.Key;
                var predicate    = pair.Value;
                var listState    = new FilteredVersionList(allVersions
                                                           .Where(predicate)
                                                           .Select(x => x.Filtered));
                _versionLists.Add(searchFilter, listState);
            }
        }
            public void LatestIsNullForEmpty()
            {
                var versions = new FilteredVersionProperties[0];

                var list = new FilteredVersionList(versions);

                Assert.Null(list._latestOrNull);
            }
            protected BaseFacts()
            {
                _initialVersionProperties  = new FilteredVersionProperties(InitialFullVersion, listed: true);
                _unlistedVersionProperties = new FilteredVersionProperties(InitialFullVersion, listed: false);

                var versions = new[] { _initialVersionProperties };

                _list = new FilteredVersionList(versions);
            }
            public void ExcludesListedVersions()
            {
                var versions = new[]
                {
                    new FilteredVersionProperties("1.0.0", listed: true),
                    new FilteredVersionProperties("1.0.1", listed: false),
                };

                var list = new FilteredVersionList(versions);

                Assert.Equal(new[] { "1.0.0" }, list.GetLatestVersionInfo().ListedFullVersions);
            }
            public void LatestIsNullForOnlyUnlisted()
            {
                var versions = new[]
                {
                    new FilteredVersionProperties("1.0.0", listed: false),
                    new FilteredVersionProperties("1.0.1", listed: false),
                };

                var list = new FilteredVersionList(versions);

                Assert.Null(list._latestOrNull);
            }
            public void UnlistedIsNotLatest()
            {
                var versions = new[]
                {
                    new FilteredVersionProperties("1.0.0", listed: true),
                    new FilteredVersionProperties("1.0.1", listed: false),
                };

                var list = new FilteredVersionList(versions);

                Assert.Equal("1.0.0", list.GetLatestVersionInfo().FullVersion);
            }
            public void OrdersBySemVer()
            {
                var versions = new[]
                {
                    new FilteredVersionProperties("10.0.0", listed: true),
                    new FilteredVersionProperties("10.0.0-alpha", listed: true),
                    new FilteredVersionProperties("10.0.0-beta.10", listed: true),
                    new FilteredVersionProperties("10.0.0-beta.2", listed: true),
                    new FilteredVersionProperties("10.0.1", listed: true),
                    new FilteredVersionProperties("2.0.0", listed: true),
                };

                var list = new FilteredVersionList(versions);

                Assert.Equal(
                    new[] { "2.0.0", "10.0.0-alpha", "10.0.0-beta.2", "10.0.0-beta.10", "10.0.0", "10.0.1" },
                    list.GetLatestVersionInfo().ListedFullVersions);
            }