本文整理汇总了C#中SharedPackageRepository.FindPackagesById方法的典型用法代码示例。如果您正苦于以下问题:C# SharedPackageRepository.FindPackagesById方法的具体用法?C# SharedPackageRepository.FindPackagesById怎么用?C# SharedPackageRepository.FindPackagesById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedPackageRepository
的用法示例。
在下文中一共展示了SharedPackageRepository.FindPackagesById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindPackagesByIdAlwaysReturnsOptimizedZipPackageEvenIfNuspecIfPresent
public void FindPackagesByIdAlwaysReturnsOptimizedZipPackageEvenIfNuspecIfPresent()
{
// Arrange
string manifestContent = @"<?xml version=""1.0""?>
<package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"">
<metadata>
<id>One</id>
<version>2.0-alpha</version>
<authors>test</authors>
<description>My package description.</description>
</metadata>
<files />
</package>";
var fileSystem = new MockFileSystem("x:\\root");
fileSystem.AddFile("one.1.0.0-alpha\\one.1.0.0-alpha.nuspec", manifestContent.AsStream());
var packageStream = PackageUtility.CreateSimplePackageStream("One", "1.0.0-alpha");
fileSystem.AddFile("one.1.0.0-alpha\\one.1.0.0-alpha.nupkg", packageStream);
var configFileSystem = new MockFileSystem();
var repository = new SharedPackageRepository(new DefaultPackagePathResolver(fileSystem), fileSystem, configFileSystem);
// Act
var packages = repository.FindPackagesById("one").ToList();
// Assert
Assert.Equal(1, packages.Count);
var package = packages[0];
Assert.True(package is OptimizedZipPackage);
Assert.Equal("One", package.Id);
Assert.Equal(new SemanticVersion("1.0.0-alpha"), package.Version);
}
示例2: FindPackagesByIdReturnsAnUnzippedInstanceIfANuspecIsAvailableAndAZipPackageOtherwise
public void FindPackagesByIdReturnsAnUnzippedInstanceIfANuspecIsAvailableAndAZipPackageOtherwise()
{
// Arrange
string manifestContent = @"<?xml version=""1.0""?>
<package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"">
<metadata>
<id>One</id>
<version>1.0-alpha</version>
<authors>test</authors>
<description>My package description.</description>
</metadata>
<files />
</package>";
var fileSystem = new MockFileSystem("x:\root");
fileSystem.AddFile("one.1.0.0-alpha\\one.1.0.0-alpha.nuspec", manifestContent.AsStream());
fileSystem.AddFile("one.1.0.0-alpha\\one.1.0.0-alpha.nupkg", Stream.Null);
var packageStream = GetPackageStream("One", "1.0.0");
fileSystem.AddFile("one.1.0\\one.1.0.nupkg", packageStream);
var configFileSystem = new MockFileSystem();
var repository = new SharedPackageRepository(new DefaultPackagePathResolver(fileSystem), fileSystem, configFileSystem);
// Act
var packages = repository.FindPackagesById("one").ToList();
// Assert
Assert.Equal(2, packages.Count);
var package = packages[0];
Assert.IsType<UnzippedPackage>(package);
Assert.Equal("One", package.Id);
Assert.Equal(new SemanticVersion("1.0.0-alpha"), package.Version);
package = packages[1];
Assert.IsType<ZipPackage>(package);
Assert.Equal("One", package.Id);
Assert.Equal(new SemanticVersion("1.0.0"), package.Version);
}