本文整理汇总了C#中SharedPackageRepository.GetRepositoryPaths方法的典型用法代码示例。如果您正苦于以下问题:C# SharedPackageRepository.GetRepositoryPaths方法的具体用法?C# SharedPackageRepository.GetRepositoryPaths怎么用?C# SharedPackageRepository.GetRepositoryPaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedPackageRepository
的用法示例。
在下文中一共展示了SharedPackageRepository.GetRepositoryPaths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRepositoryPathsRemovesInvalidOrNonExistantPathsAndReturnsRelativePaths
public void GetRepositoryPathsRemovesInvalidOrNonExistantPathsAndReturnsRelativePaths()
{
// Arrange
var fileSystem = new Mock<MockFileSystem>() { CallBase = true };
fileSystem.Setup(m => m.FileExists(@"A\packages.config")).Returns(true);
fileSystem.Setup(m => m.FileExists(@"c:\foo\packages.config")).Returns(true);
fileSystem.Setup(m => m.FileExists(@"..\..\packages.config")).Returns(true);
fileSystem.Object.AddFile("repositories.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<repositories>
<repository path=""A\packages.config"" />
<repository path=""B\packages.config"" />
<repository path=""c:\foo\packages.config"" />
<repository path=""..\..\packages.config"" />
<repository path="""" />
<repository />
</repositories>");
fileSystem.Setup(m => m.Root).Returns(@"c:\foo\bar\baz\");
var repository = new SharedPackageRepository(new DefaultPackagePathResolver(fileSystem.Object), fileSystem.Object);
// Act
var paths = repository.GetRepositoryPaths().ToList();
// Assert
Assert.Equal(2, paths.Count);
Assert.Equal(@"A\packages.config", paths[0]);
Assert.Equal(@"..\..\packages.config", paths[1]);
Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?>
<repositories>
<repository path=""A\packages.config"" />
<repository path=""c:\foo\packages.config"" />
</repositories>", fileSystem.Object.ReadAllText("repositories.config"));
}
示例2: GetRepositoryPathsRemovesInvalidOrNonExistantPathsAndReturnsRelativePaths
public void GetRepositoryPathsRemovesInvalidOrNonExistantPathsAndReturnsRelativePaths()
{
// Arrange
var fileSystem = new MockFileSystem(@"x:\foo\bar\baz");
fileSystem.AddFile(@"A\packages.config", "");
fileSystem.AddFile(@"x:\foo\packages.config", "");
fileSystem.AddFile(@"..\..\packages.config", "");
fileSystem.AddFile("repositories.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<repositories>
<repository path=""A\packages.config"" />
<repository path=""B\packages.config"" />
<repository path=""x:\foo\packages.config"" />
<repository path=""..\..\packages.config"" />
<repository path="""" />
<repository />
</repositories>");
var repository = new SharedPackageRepository(new DefaultPackagePathResolver(fileSystem), fileSystem, new MockFileSystem());
// Act
var paths = repository.GetRepositoryPaths().ToList();
// Assert
Assert.Equal(2, paths.Count);
Assert.Equal(@"A\packages.config", paths[0]);
Assert.Equal(@"..\..\packages.config", paths[1]);
Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?>
<repositories>
<repository path=""A\packages.config"" />
<repository path=""x:\foo\packages.config"" />
</repositories>", fileSystem.ReadAllText("repositories.config"));
}