本文整理汇总了C#中TestableV2Feed.FindPackagesById方法的典型用法代码示例。如果您正苦于以下问题:C# TestableV2Feed.FindPackagesById方法的具体用法?C# TestableV2Feed.FindPackagesById怎么用?C# TestableV2Feed.FindPackagesById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestableV2Feed
的用法示例。
在下文中一共展示了TestableV2Feed.FindPackagesById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: V2FeedFindPackagesByIdReturnsUnlistedAndPrereleasePackages
public void V2FeedFindPackagesByIdReturnsUnlistedAndPrereleasePackages()
{
// 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.Setup(c => c.GetSiteRoot(It.IsAny<bool>())).Returns("https://localhost:8081/");
var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null);
// Act
var result = v2Service.FindPackagesById("Foo");
// Assert
Assert.Equal(2, result.Count());
Assert.Equal("Foo", result.First().Id);
Assert.Equal("1.0.0", result.First().Version);
Assert.Equal("Foo", result.Last().Id);
Assert.Equal("1.0.1-a", result.Last().Version);
}
示例2: V2FeedFindPackagesByIdReturnsUnlistedAndPrereleasePackages
public void V2FeedFindPackagesByIdReturnsUnlistedAndPrereleasePackages()
{
// 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>(),
FlattenedAuthors = string.Empty,
Description = string.Empty,
Summary = string.Empty,
Tags = string.Empty
},
new Package
{
PackageRegistration = packageRegistration,
Version = "1.0.1-a",
IsPrerelease = true,
Listed = true,
DownloadStatistics = new List<PackageStatistics>(),
FlattenedAuthors = string.Empty,
Description = string.Empty,
Summary = string.Empty,
Tags = string.Empty
},
}.AsQueryable());
var configuration = new Mock<ConfigurationService>(MockBehavior.Strict);
configuration.Setup(c => c.GetSiteRoot(It.IsAny<bool>())).Returns("https://localhost:8081/");
configuration.Setup(c => c.Features).Returns(new FeatureConfiguration() { FriendlyLicenses = true });
var searchService = new Mock<ISearchService>(MockBehavior.Strict);
searchService.Setup(s => s.Search(It.IsAny<SearchFilter>())).Returns
<IQueryable<Package>, string>((_, __) => Task.FromResult(new SearchResults(_.Count(), DateTime.UtcNow, _)));
searchService.Setup(s => s.ContainsAllVersions).Returns(false);
var v2Service = new TestableV2Feed(repo.Object, configuration.Object, searchService.Object);
// Act
var result = v2Service.FindPackagesById("Foo");
// Assert
Assert.Equal(2, result.Count());
Assert.Equal("Foo", result.First().Id);
Assert.Equal("1.0.0", result.First().Version);
Assert.Equal("Foo", result.Last().Id);
Assert.Equal("1.0.1-a", result.Last().Version);
}