diff --git a/Facts/Services/FeedServiceFacts.cs b/Facts/Services/FeedServiceFacts.cs index 1f1c179bdb..66e314c689 100644 --- a/Facts/Services/FeedServiceFacts.cs +++ b/Facts/Services/FeedServiceFacts.cs @@ -319,11 +319,11 @@ public void V2FeedGetUpdatesReturnsVersionsConformingToConstraints() // Act var result = v2Service.GetUpdates( - "Foo|Qux", - "1.0.0|0.9", - includePrerelease: false, - includeAllVersions: true, - targetFrameworks: null, + "Foo|Qux", + "1.0.0|0.9", + includePrerelease: false, + includeAllVersions: true, + targetFrameworks: null, versionConstraints: "(,1.2.0)|[2.0,2.3]") .ToList(); @@ -443,6 +443,40 @@ public void V2FeedGetUpdatesReturnsEmptyPackagesIfNoPackageSatisfiesConstraints( Assert.Equal(0, result.Count); } + [Fact] + public void V2FeedGetUpdatesReturnsCaseInsensitiveMatches() + { + // Arrange + var packageRegistrationA = new PackageRegistration { Id = "Foo" }; + var repo = new Mock>(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(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); + } + [Fact] public void V2FeedGetUpdatesReturnsUpdateIfAnyOfTheProvidedVersionsIsOlder() { @@ -501,7 +535,13 @@ public void V2FeedGetUpdatesReturnsPrereleasePackages() var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null); // Act - var result = v2Service.GetUpdates("Foo|Qux", "1.1.0|0.9", includePrerelease: true, includeAllVersions: true, targetFrameworks: null, versionConstraints: null) + var result = v2Service.GetUpdates( + "Foo|Qux", + "1.1.0|0.9", + includePrerelease: true, + includeAllVersions: true, + targetFrameworks: null, + versionConstraints: null) .ToList(); // Assert @@ -533,7 +573,13 @@ public void V2FeedGetUpdatesReturnsResultsIfDuplicatesInPackageList() // Act var result = - v2Service.GetUpdates("Foo|Qux|Foo", "0.9|1.5|1.1.2", includePrerelease: false, includeAllVersions: true, targetFrameworks: null, versionConstraints: null) + v2Service.GetUpdates( + "Foo|Qux|Foo", + "0.9|1.5|1.1.2", + includePrerelease: false, + includeAllVersions: true, + targetFrameworks: null, + versionConstraints: null) .ToList(); // Assert diff --git a/Website/DataServices/V2Feed.svc.cs b/Website/DataServices/V2Feed.svc.cs index 654d9096d3..54ff20ea04 100644 --- a/Website/DataServices/V2Feed.svc.cs +++ b/Website/DataServices/V2Feed.svc.cs @@ -62,7 +62,12 @@ public IQueryable FindPackagesById(string id) [WebGet] public IQueryable GetUpdates( - string packageIds, string versions, bool includePrerelease, bool includeAllVersions, string targetFrameworks, string versionConstraints) + string packageIds, + string versions, + bool includePrerelease, + bool includeAllVersions, + string targetFrameworks, + string versionConstraints) { if (String.IsNullOrEmpty(packageIds) || String.IsNullOrEmpty(versions)) { @@ -77,7 +82,7 @@ public IQueryable FindPackagesById(string id) targetFrameworks = targetFrameworks.Replace(' ', '+'); } - var idValues = packageIds.Trim().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + var idValues = packageIds.Trim().ToLowerInvariant().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var versionValues = versions.Trim().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var targetFrameworkValues = String.IsNullOrEmpty(targetFrameworks) ? null @@ -110,13 +115,16 @@ public IQueryable FindPackagesById(string id) return null; }) .Where(t => t != null) - .ToLookup(t => t.Item1, t => t.Item2); + .ToLookup(t => t.Item1, t => t.Item2, StringComparer.OrdinalIgnoreCase); var packages = PackageRepository.GetAll() .Include(p => p.PackageRegistration) .Include(p => p.SupportedFrameworks) - .Where(p => p.Listed && (includePrerelease || !p.IsPrerelease) && idValues.Contains(p.PackageRegistration.Id)) + .Where(p => + p.Listed && (includePrerelease || !p.IsPrerelease) && + idValues.Contains(p.PackageRegistration.Id.ToLower())) .OrderBy(p => p.PackageRegistration.Id); + return GetUpdates(packages, versionLookup, targetFrameworkValues, includeAllVersions).AsQueryable() .ToV2FeedPackageQuery(GetSiteRoot()); }