public void V2FeedGetUpdatesFiltersByTargetFramework() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var packageRegistrationB = new PackageRegistration { Id = "Qux" }; var repo = new Mock <IEntityRepository <Package> >(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns(new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true, SupportedFrameworks = new[] { new PackageFramework { TargetFramework = "SL5" }, new PackageFramework { TargetFramework = "Net40-Full" } } }, new Package { PackageRegistration = packageRegistrationA, Version = "1.3.0-alpha", IsPrerelease = true, Listed = true, SupportedFrameworks = new[] { new PackageFramework { TargetFramework = "SL5" }, new PackageFramework { TargetFramework = "Net40-Full" } } }, new Package { PackageRegistration = packageRegistrationA, Version = "2.0.0", IsPrerelease = false, Listed = true, SupportedFrameworks = new[] { new PackageFramework { TargetFramework = "SL5" }, new PackageFramework { TargetFramework = "WinRT" } } }, new Package { PackageRegistration = packageRegistrationB, Version = "2.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock <IConfiguration>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates("Foo|Qux", "1.0|1.5", includePrerelease: false, includeAllVersions: true, targetFrameworks: "net40") .ToList(); // Assert Assert.Equal(2, result.Count); AssertPackage(new { Id = "Foo", Version = "1.1.0" }, result[0]); AssertPackage(new { Id = "Qux", Version = "2.0" }, result[1]); }
public void V2FeedGetUpdatesIgnoreInvalidVersionConstraints() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var packageRegistrationB = new PackageRegistration { Id = "Qux" }; var repo = new Mock <IEntityRepository <Package> >(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns( new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "3.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock <IConfiguration>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates( "Foo|Qux", "1.0.0|0.9", includePrerelease: false, includeAllVersions: true, targetFrameworks: null, versionConstraints: "(,1.2.0)|abdfsdf") .ToList(); // Assert Assert.Equal(3, result.Count); AssertPackage(new { Id = "Foo", Version = "1.1.0" }, result[0]); AssertPackage(new { Id = "Qux", Version = "2.0" }, result[1]); AssertPackage(new { Id = "Qux", Version = "3.0" }, result[2]); }
public void V2FeedGetUpdatesReturnsEmptyIfVersionConstraintsContainWrongNumberOfElements(string constraintString) { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var packageRegistrationB = new PackageRegistration { Id = "Qux" }; var repo = new Mock <IEntityRepository <Package> >(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns( new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "3.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock <ConfigurationService>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates( "Foo|Qux", "1.0.0|0.9", includePrerelease: false, includeAllVersions: true, targetFrameworks: null, versionConstraints: constraintString) .ToList(); // Assert Assert.Equal(0, result.Count); }
public void V2FeedGetUpdatesReturnsEmptyResultsIfInputIsMalformed(string id, string version) { // Arrange var repo = Mock.Of <IEntityRepository <Package> >(); var configuration = Mock.Of <IConfiguration>(); var v2Service = new TestableV2Feed(repo, configuration, null); // Act var result = v2Service.GetUpdates(id, version, includePrerelease: false, includeAllVersions: true, targetFrameworks: null, versionConstraints: null) .ToList(); // Assert Assert.Empty(result); }
public void V2FeedGetUpdatesReturnsCaseInsensitiveMatches() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var repo = new Mock <IEntityRepository <Package> >(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns( new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock <ConfigurationService>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates( "foo", "1.0.0", includePrerelease: false, includeAllVersions: false, targetFrameworks: null, versionConstraints: null) .ToList(); // Assert Assert.Equal(1, result.Count); Assert.Equal("Foo", result[0].Id); Assert.Equal("1.2.0", result[0].Version); }
public void V2FeedGetUpdatesFiltersIncludesHighestPrereleasePackage() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var packageRegistrationB = new PackageRegistration { Id = "Qux" }; var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns( new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true, SupportedFrameworks = new[] { new PackageFramework { TargetFramework = "SL5" }, new PackageFramework { TargetFramework = "Net40-Full" } } }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true, SupportedFrameworks = new[] { new PackageFramework { TargetFramework = "SL5" }, new PackageFramework { TargetFramework = "Net40-Full" } } }, new Package { PackageRegistration = packageRegistrationA, Version = "1.3.0-alpha", IsPrerelease = true, Listed = true, SupportedFrameworks = new[] { new PackageFramework { TargetFramework = "SL5" }, new PackageFramework { TargetFramework = "Net40-Full" } } }, new Package { PackageRegistration = packageRegistrationA, Version = "2.0.0", IsPrerelease = false, Listed = true, SupportedFrameworks = new[] { new PackageFramework { TargetFramework = "SL5" }, new PackageFramework { TargetFramework = "WinRT" } } }, new Package { PackageRegistration = packageRegistrationB, Version = "2.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock<ConfigurationService>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); configuration.Setup(c => c.Features).Returns(new FeatureConfiguration() { FriendlyLicenses = true }); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates("Foo|Qux", "1.0|1.5", includePrerelease: true, includeAllVersions: false, targetFrameworks: "net40", versionConstraints: null) .ToList(); // Assert Assert.Equal(2, result.Count); AssertPackage(new { Id = "Foo", Version = "1.3.0-alpha" }, result[0]); AssertPackage(new { Id = "Qux", Version = "2.0" }, result[1]); }
public void V2FeedGetUpdatesReturnsCaseInsensitiveMatches() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns( new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock<ConfigurationService>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); configuration.Setup(c => c.Features).Returns(new FeatureConfiguration() { FriendlyLicenses = true }); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates( "foo", "1.0.0", includePrerelease: false, includeAllVersions: false, targetFrameworks: null, versionConstraints: null) .ToList(); // Assert Assert.Equal(1, result.Count); Assert.Equal("Foo", result[0].Id); Assert.Equal("1.2.0", result[0].Version); }
public void V2FeedGetUpdatesReturnsVersionsConformingToConstraintsWithMissingConstraintsForSomePackges() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var packageRegistrationB = new PackageRegistration { Id = "Qux" }; var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns( new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "3.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock<ConfigurationService>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); configuration.Setup(c => c.Features).Returns(new FeatureConfiguration() { FriendlyLicenses = true }); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates( "Foo|Qux", "1.0.0|0.9", includePrerelease: false, includeAllVersions: false, targetFrameworks: null, versionConstraints: "|(1.2,2.8)") .ToList(); // Assert Assert.Equal(2, result.Count); AssertPackage(new { Id = "Foo", Version = "1.2.0" }, result[0]); AssertPackage(new { Id = "Qux", Version = "2.0" }, result[1]); }
public void V2FeedGetUpdatesReturnsEmptyResultsIfInputIsMalformed(string id, string version) { // Arrange var repo = Mock.Of<IEntityRepository<Package>>(); var configuration = Mock.Of<ConfigurationService>(); var v2Service = new TestableV2Feed(repo, configuration, null); // Act var result = v2Service.GetUpdates(id, version, includePrerelease: false, includeAllVersions: true, targetFrameworks: null, versionConstraints: null) .ToList(); // Assert Assert.Empty(result); }
public void V2FeedGetUpdatesIgnoresDuplicatesInPackageList() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var packageRegistrationB = new PackageRegistration { Id = "Qux" }; var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns(new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "2.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock<IConfiguration>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates("Foo|Qux|Foo", "0.9|1.5|1.1.2", includePrerelease: false, includeAllVersions: true, targetFrameworks: null) .ToList(); // Assert Assert.Equal(2, result.Count); AssertPackage(new { Id = "Foo", Version = "1.2.0" }, result[0]); AssertPackage(new { Id = "Qux", Version = "2.0" }, result[1]); }
public void V2FeedGetUpdatesReturnsEmptyPackagesIfNoPackageSatisfiesConstraints() { // Arrange var packageRegistrationA = new PackageRegistration { Id = "Foo" }; var packageRegistrationB = new PackageRegistration { Id = "Qux" }; var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns( new[] { new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true }, new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "2.0", IsPrerelease = false, Listed = true }, new Package { PackageRegistration = packageRegistrationB, Version = "3.0", IsPrerelease = false, Listed = true }, }.AsQueryable()); var configuration = new Mock<ConfigurationService>(MockBehavior.Strict); configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/"); var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act var result = v2Service.GetUpdates( "Foo|Qux", "1.0.0|0.9", includePrerelease: false, includeAllVersions: false, targetFrameworks: null, versionConstraints: "3.4|4.0") .ToList(); // Assert Assert.Equal(0, result.Count); }