public void V1FeedFindPackagesByIdReturnsUnlistedPackagesButNotPrereleasePackages() { // Arrange var packageRegistration = new PackageRegistration { Id = "Foo" }; var repo = new Mock <IEntityRepository <Package> >(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns(new[] { new Package { PackageRegistration = packageRegistration, Version = "1.0.0", IsPrerelease = false, Listed = false, DownloadStatistics = new List <PackageStatistics>() }, new Package { PackageRegistration = packageRegistration, Version = "1.0.1-a", IsPrerelease = true, Listed = true, DownloadStatistics = new List <PackageStatistics>() }, }.AsQueryable()); var configuration = new Mock <IConfiguration>(MockBehavior.Strict); configuration.SetupGet(c => c.SiteRoot).Returns("https://localhost:8081/"); var v1Service = new V1Feed(repo.Object, configuration.Object, null); // Act var result = v1Service.FindPackagesById("Foo"); // Assert Assert.Equal(1, result.Count()); Assert.Equal("Foo", result.First().Id); Assert.Equal("1.0.0", result.First().Version); Assert.Equal("https://localhost:8081/packages/Foo/1.0.0", result.First().GalleryDetailsUrl); }
public void V1FeedFindPackagesByIdReturnsUnlistedPackagesButNotPrereleasePackages() { // Arrange var packageRegistration = new PackageRegistration { Id = "Foo" }; var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict); repo.Setup(r => r.GetAll()).Returns(new[] { new Package { PackageRegistration = packageRegistration, Version = "1.0.0", IsPrerelease = false, Listed = false, DownloadStatistics = new List<PackageStatistics>() }, new Package { PackageRegistration = packageRegistration, Version = "1.0.1-a", IsPrerelease = true, Listed = true, DownloadStatistics = new List<PackageStatistics>() }, }.AsQueryable()); var configuration = new Mock<IConfiguration>(MockBehavior.Strict); configuration.SetupGet(c => c.SiteRoot).Returns("https://localhost:8081/"); var v1Service = new V1Feed(repo.Object, configuration.Object, null); // Act var result = v1Service.FindPackagesById("Foo"); // Assert Assert.Equal(1, result.Count()); Assert.Equal("Foo", result.First().Id); Assert.Equal("1.0.0", result.First().Version); Assert.Equal("https://localhost:8081/packages/Foo/1.0.0", result.First().GalleryDetailsUrl); }