Beispiel #1
0
        public void Filter3Only1SupportedMultipleTfmsNoMatches()
        {
            // Arrange
            var item1 = _fixture.Create <NuGetReference>() with {
                Version = "1.0.0"
            };
            var item2 = item1 with {
                Version = "2.0.0"
            };
            var item3 = item1 with {
                Version = "3.0.0"
            };

            var metadata1 = MockSearchMetadata(item1, TargetFrameworkMoniker.Net45, TargetFrameworkMoniker.NetCoreApp21);
            var metadata2 = MockSearchMetadata(item2, TargetFrameworkMoniker.Net45, TargetFrameworkMoniker.Net50);
            var metadata3 = MockSearchMetadata(item3, TargetFrameworkMoniker.Net50_Linux, TargetFrameworkMoniker.Net50_Windows);

            foreach (var metadata in Permute(metadata1, metadata2, metadata3))
            {
                // Act
                var result = PackageLoader.FilterSearchResults(item1.Name, metadata, new[] { TargetFrameworkMoniker.Net50, TargetFrameworkMoniker.NetStandard20 });

                // Assert
                Assert.Empty(result);
            }
        }
Beispiel #2
0
        public void FilterOnly()
        {
            // Arrange
            var item1 = _fixture.Create <NuGetReference>() with {
                Version = "1.0.0"
            };
            var item2 = item1 with {
                Version = "1.1.0"
            };
            var item3 = item1 with {
                Version = "1.2.0"
            };
            var item4 = item1 with {
                Version = "2.1.0"
            };

            var metadata1 = MockSearchMetadata(item1, TargetFrameworkMoniker.NetStandard20);
            var metadata2 = MockSearchMetadata(item2, TargetFrameworkMoniker.NetStandard20);
            var metadata3 = MockSearchMetadata(item3, TargetFrameworkMoniker.NetStandard20);
            var metadata4 = MockSearchMetadata(item4, TargetFrameworkMoniker.NetStandard20);

            foreach (var metadata in Permute(metadata1, metadata2, metadata3, metadata4))
            {
                // Act
                var result = PackageLoader.FilterSearchResults(item1.Name, metadata, new[] { TargetFrameworkMoniker.Net50 }, latestMinorAndBuildOnly: true);

                // Assert
                Assert.Collection(result,
                                  r => Assert.Equal(r, item3),
                                  r => Assert.Equal(r, item4));
            }
        }
Beispiel #3
0
        public void Filter3Only1Supported()
        {
            // Arrange
            var item1 = _fixture.Create <NuGetReference>() with {
                Version = "1.0.0"
            };
            var item2 = item1 with {
                Version = "2.0.0"
            };
            var item3 = item1 with {
                Version = "3.0.0"
            };

            var metadata1 = MockSearchMetadata(item1, TargetFrameworkMoniker.Net45);
            var metadata2 = MockSearchMetadata(item2, TargetFrameworkMoniker.Net50);
            var metadata3 = MockSearchMetadata(item3, TargetFrameworkMoniker.Net60);

            foreach (var metadata in Permute(metadata1, metadata2, metadata3))
            {
                // Act
                var result = PackageLoader.FilterSearchResults(item1.Name, metadata, new[] { TargetFrameworkMoniker.Net50 });

                // Assert
                Assert.Collection(result, r => Assert.Equal(r, item2));
            }
        }
Beispiel #4
0
        public void FilterExplicitMatch()
        {
            // Arrange
            var item = _fixture.Create <NuGetReference>() with {
                Version = "1.0.0"
            };
            var tfm      = TargetFrameworkMoniker.NetStandard20;
            var metadata = MockSearchMetadata(item, tfm);

            // Act
            var result = PackageLoader.FilterSearchResults(item.Name, new[] { metadata }, new[] { tfm });

            // Assert
            Assert.Collection(result, r => Assert.Equal(r, item));
        }
Beispiel #5
0
        public void FilterSupported(bool isBackwards)
        {
            // Arrange
            var item1 = _fixture.Create <NuGetReference>() with {
                Version = "1.0.0"
            };
            var item2 = item1 with {
                Version = "2.0.0"
            };
            var metadata1 = MockSearchMetadata(item1, TargetFrameworkMoniker.NetStandard20);
            var metadata2 = MockSearchMetadata(item2, TargetFrameworkMoniker.Net50);

            var list = isBackwards ? new[] { metadata2, metadata1 } : new[] { metadata1, metadata2 };

            // Act
            var result = PackageLoader.FilterSearchResults(item1.Name, list, new[] { TargetFrameworkMoniker.Net50 });

            // Assert
            Assert.Collection(result,
                              r => Assert.Equal(r, item1),
                              r => Assert.Equal(r, item2));
        }