Permalink
Browse files

Remove duplicate target frameworks.

  • Loading branch information...
1 parent 157cd73 commit 269a72b347983ecbbb0c6f485b47bff5e718edbc @chriseldredge chriseldredge committed Jun 22, 2012
Showing with 27 additions and 5 deletions.
  1. +1 −1 src/Server/DataServices/Packages.svc.cs
  2. +26 −4 test/Server.Test/PackageSvcFacts.cs
@@ -118,7 +118,7 @@ public object GetService(Type serviceType)
[WebGet]
public IQueryable<Package> Search(string searchTerm, string targetFramework, bool includePrerelease)
{
- IEnumerable<string> targetFrameworks = String.IsNullOrEmpty(targetFramework) ? Enumerable.Empty<string>() : targetFramework.Split('|');
+ IEnumerable<string> targetFrameworks = String.IsNullOrEmpty(targetFramework) ? Enumerable.Empty<string>() : targetFramework.Split('|').Distinct();
return from package in Repository.Search(searchTerm, targetFrameworks, includePrerelease)
select Repository.GetMetadataPackage(package);
@@ -3,14 +3,25 @@
using System.Data.Services;
using System.Linq;
using System.ServiceModel.Web;
-using Moq;
-using NuGet.Server.DataServices;
+using Moq;
+using NuGet;
+using NuGet.Server.DataServices;
+using NuGet.Server.Infrastructure;
using Xunit;
namespace Server.Test
{
- public class PackageSvcFacts
- {
+ public class PackageSvcFacts
+ {
+ private readonly Mock<IServerPackageRepository> repository;
+ private readonly Packages service;
+
+ public PackageSvcFacts()
+ {
+ repository = new Mock<IServerPackageRepository>();
+ service = new Packages(new Lazy<IServerPackageRepository>(() => repository.Object));
+ }
+
[Fact]
public void EnsureAllDeclaredServicesAreRegistered()
{
@@ -30,5 +41,16 @@ public void EnsureAllDeclaredServicesAreRegistered()
Assert.Equal(expectedServices.OrderBy(s => s, StringComparer.Ordinal),
registeredServices.OrderBy(s => s, StringComparer.Ordinal));
}
+
+ [Fact]
+ public void SearchWithDistinctTargetFrameworks()
+ {
+ var result = new IPackage[0].AsQueryable();
+ repository.Setup(repo => repo.Search("term", new[] {"net40", "net40-client"}, false)).Returns(result).Verifiable();
+
+ service.Search("term", "net40|net40|net40-client|net40", false);
+
+ repository.Verify();
+ }
}
}

0 comments on commit 269a72b

Please sign in to comment.