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