本文整理汇总了C#中AssemblyResolver.GetAssemblyPaths方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyResolver.GetAssemblyPaths方法的具体用法?C# AssemblyResolver.GetAssemblyPaths怎么用?C# AssemblyResolver.GetAssemblyPaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssemblyResolver
的用法示例。
在下文中一共展示了AssemblyResolver.GetAssemblyPaths方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldOnlyReturnBinariesWhenFlagIsSet
public void ShouldOnlyReturnBinariesWhenFlagIsSet(
[Frozen] Mock<IPackageAssemblyResolver> packageAssemblyResolverMock,
[Frozen] Mock<IFileSystem> fileSystemMock,
[Frozen] Mock<IAssemblyUtility> assemblyUtilityMock,
AssemblyResolver resolver)
{
const string WorkingDirectory = @"C:\";
var binFolder = Path.Combine(WorkingDirectory, "bin");
assemblyUtilityMock.Setup(a => a.IsManagedAssembly(It.IsAny<string>())).Returns(true);
fileSystemMock.Setup(x => x.DirectoryExists(binFolder)).Returns(true);
fileSystemMock.Setup(x => x.DirectoryExists(@"C:\packages")).Returns(true);
fileSystemMock.SetupGet(x => x.PackagesFolder).Returns("packages");
fileSystemMock.SetupGet(x => x.BinFolder).Returns("bin");
fileSystemMock.Setup(x => x.EnumerateFiles(binFolder, It.IsAny<string>(), SearchOption.AllDirectories))
.Returns(Enumerable.Empty<string>());
packageAssemblyResolverMock.Setup(p=>p.GetAssemblyNames(WorkingDirectory)).Returns(new string[] {"test.dll", "test.exe", "test.foo"});
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory, true).ToList();
assemblies.ShouldNotContain("test.foo");
assemblies.ShouldContain("test.dll");
assemblies.ShouldContain("test.exe");
}
示例2: ShouldNotReturnNonManagedAssemblies
public void ShouldNotReturnNonManagedAssemblies(
[Frozen] Mock<IFileSystem> fileSystemMock,
[Frozen] Mock<IPackageAssemblyResolver> packageAssemblyResolverMock,
[Frozen] Mock<IAssemblyUtility> assemblyUtilityMock,
AssemblyResolver resolver
)
{
const string WorkingDirectory = @"C:\";
var binFolder = Path.Combine(WorkingDirectory, "bin");
var managed = Path.Combine(binFolder, "MyAssembly.dll");
var nonManaged = Path.Combine(binFolder, "MyNonManagedAssembly.dll");
fileSystemMock.Setup(x => x.DirectoryExists(binFolder)).Returns(true);
fileSystemMock.SetupGet(x => x.PackagesFolder).Returns("packages");
fileSystemMock.SetupGet(x => x.BinFolder).Returns("bin");
fileSystemMock.Setup(x => x.EnumerateFiles(binFolder, It.IsAny<string>(), SearchOption.TopDirectoryOnly
))
.Returns(new[] { managed, nonManaged });
assemblyUtilityMock.Setup(x => x.IsManagedAssembly(managed)).Returns(true);
assemblyUtilityMock.Setup(x => x.IsManagedAssembly(nonManaged)).Returns(false);
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory).ToList();
assemblies.Count.ShouldEqual(1);
assemblies[0].ShouldEqual(managed);
}
示例3: ShouldNotReturnScriptDll
public void ShouldNotReturnScriptDll()
{
const string WorkingDirectory = @"C:\";
var binFolder = Path.Combine(WorkingDirectory, "bin");
var scriptDll = Path.Combine(binFolder, "script.dll");
var fileSystem = new Mock<IFileSystem>();
fileSystem.Setup(x => x.DirectoryExists(binFolder)).Returns(true);
fileSystem.Setup(x => x.EnumerateFiles(binFolder, It.IsAny<string>(), SearchOption.AllDirectories))
.Returns(new[] { scriptDll });
var assemblyUtility = new Mock<IAssemblyUtility>();
assemblyUtility.Setup(x => x.IsManagedAssembly(scriptDll)).Returns(true);
var resolver = new AssemblyResolver(fileSystem.Object, Mock.Of<IPackageAssemblyResolver>(), assemblyUtility.Object, Mock.Of<ILog>());
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory, "script.csx").ToList();
assemblies.Count.ShouldEqual(0);
}
示例4: ShouldReturnAssembliesFromBinFolder
public void ShouldReturnAssembliesFromBinFolder()
{
const string WorkingDirectory = @"C:\";
var binFolder = Path.Combine(WorkingDirectory, Constants.BinFolder);
var assemblyFile = Path.Combine(binFolder, "MyAssembly.dll");
var fileSystem = new Mock<IFileSystem>();
fileSystem.Setup(x => x.DirectoryExists(binFolder)).Returns(true);
fileSystem.Setup(x => x.EnumerateFiles(binFolder, It.IsAny<string>(), SearchOption.AllDirectories)).Returns(new[] { assemblyFile });
var assemblyUtility = new Mock<IAssemblyUtility>();
assemblyUtility.Setup(x => x.IsManagedAssembly(assemblyFile)).Returns(true);
var resolver = new AssemblyResolver(fileSystem.Object, Mock.Of<IPackageAssemblyResolver>(), assemblyUtility.Object, Mock.Of<ILog>());
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory).ToList();
assemblies.Count.ShouldEqual(1);
assemblies[0].ShouldEqual(assemblyFile);
}
示例5: ShouldReturnAssembliesFromPackagesFolder
public void ShouldReturnAssembliesFromPackagesFolder(
[Frozen] Mock<IFileSystem> fileSystemMock,
[Frozen] Mock<IPackageAssemblyResolver> packageAssemblyResolverMock,
AssemblyResolver resolver
)
{
const string WorkingDirectory = @"C:\";
var packagesFolder = Path.Combine(WorkingDirectory, "packages");
var assemblyFile = Path.Combine(packagesFolder, "MyAssembly.dll");
fileSystemMock.Setup(x => x.DirectoryExists(packagesFolder)).Returns(true);
fileSystemMock.SetupGet(x => x.PackagesFolder).Returns("packages");
fileSystemMock.SetupGet(x => x.BinFolder).Returns("bin");
packageAssemblyResolverMock.Setup(x => x.GetAssemblyNames(WorkingDirectory)).Returns(new[] { assemblyFile });
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory).ToList();
assemblies.Count.ShouldEqual(1);
assemblies[0].ShouldEqual(assemblyFile);
}
示例6: ShouldReturnAssembliesFromPackagesFolder
public void ShouldReturnAssembliesFromPackagesFolder()
{
const string WorkingDirectory = @"C:\";
var packagesFolder = Path.Combine(WorkingDirectory, Constants.PackagesFolder);
var assemblyFile = Path.Combine(packagesFolder, "MyAssembly.dll");
var fileSystem = new Mock<IFileSystem>();
fileSystem.Setup(x => x.DirectoryExists(packagesFolder)).Returns(true);
var packageAssemblyResolver = new Mock<IPackageAssemblyResolver>();
packageAssemblyResolver.Setup(x => x.GetAssemblyNames(WorkingDirectory)).Returns(new[] { assemblyFile });
var resolver = new AssemblyResolver(fileSystem.Object, packageAssemblyResolver.Object, Mock.Of<IAssemblyUtility>(), Mock.Of<ILog>());
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory, "script.csx").ToList();
assemblies.Count.ShouldEqual(1);
assemblies[0].ShouldEqual(assemblyFile);
}