本文整理汇总了C#中PackageReferenceRepository.GetPackages方法的典型用法代码示例。如果您正苦于以下问题:C# PackageReferenceRepository.GetPackages方法的具体用法?C# PackageReferenceRepository.GetPackages怎么用?C# PackageReferenceRepository.GetPackages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageReferenceRepository
的用法示例。
在下文中一共展示了PackageReferenceRepository.GetPackages方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPackagesNoPackagesConfigReturnsEmptyList
public void GetPackagesNoPackagesConfigReturnsEmptyList()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var fileSystem = new MockFileSystem();
var referenceRepository = new PackageReferenceRepository(fileSystem, repository.Object);
// Act
var packages = referenceRepository.GetPackages().ToList();
// Assert
Assert.AreEqual(0, packages.Count);
}
示例2: GetPackagesWithMalformedPackagesConfigThrows
public void GetPackagesWithMalformedPackagesConfigThrows()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package ");
var referenceRepository = new PackageReferenceRepository(fileSystem, repository.Object);
// Act
ExceptionAssert.Throws<InvalidOperationException>(() => referenceRepository.GetPackages().ToList(), @"Error reading 'C:\MockFileSystem\packages.config'.");
}
示例3: GetPackagesReturnsOnlyValidPackagesFromSourceRepositoryListedInPackagesConfig
public void GetPackagesReturnsOnlyValidPackagesFromSourceRepositoryListedInPackagesConfig()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var packageC = PackageUtility.CreatePackage("C", "2.0");
repository.Object.AddPackage(packageC);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""C"" version=""2.0"" />
<package id=""B"" version=""1.0"" />
<package id=""A"" version=""1.0"" />
<package id="""" version=""1.0"" />
<package id=""G"" version="""" />
<package />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, repository.Object);
// Act
var packages = referenceRepository.GetPackages().ToList();
// Assert
Assert.Equal(2, packages.Count);
Assert.Same(packageC, packages[0]);
Assert.Same(packageA, packages[1]);
Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""C"" version=""2.0"" />
<package id=""B"" version=""1.0"" />
<package id=""A"" version=""1.0"" />
<package id="""" version=""1.0"" />
<package id=""G"" version="""" />
<package />
</packages>", fileSystem.ReadAllText("packages.config"));
}
示例4: GetPackagesLoadsPlainPackagesConfigIfProjectPackagesConfigDoesNotExist
public void GetPackagesLoadsPlainPackagesConfigIfProjectPackagesConfigDoesNotExist()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.cool.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
</packages>");
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""B"" version=""1.0"" />
<package id=""C"" version=""1.0"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, projectName: "cool", sourceRepository: repository.Object);
// Act
var packages = referenceRepository.GetPackages().ToList();
// Assert
Assert.Equal(1, packages.Count);
Assert.Same(packageA, packages[0]);
Assert.True(fileSystem.FileExists("packages.cool.config"));
}
示例5: GetPackagesReturnsPackagesFromSourceRepositoryListedInPackagesConfig
public void GetPackagesReturnsPackagesFromSourceRepositoryListedInPackagesConfig()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, projectName: null, sourceRepository: repository.Object);
// Act
var packages = referenceRepository.GetPackages().ToList();
// Assert
Assert.Equal(1, packages.Count);
Assert.Same(packageA, packages[0]);
}