public void TestMultipleNativeDependencies() { string oneNativeLibraryPath = CreateMockStandardNativeLibrary($"native{Path.DirectorySeparatorChar}one", "One"); string twoNativeLibraryPath = CreateMockStandardNativeLibrary($"native{Path.DirectorySeparatorChar}two", "Two"); using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( 0, "", $"{Path.GetDirectoryName(oneNativeLibraryPath)}{Path.PathSeparator}{Path.GetDirectoryName(twoNativeLibraryPath)}", "")) { AssemblyDependencyResolver resolver = new AssemblyDependencyResolver( Path.Combine(TestBasePath, _componentAssemblyPath)); Assert.Equal( oneNativeLibraryPath, resolver.ResolveUnmanagedDllToPath("One")); Assert.Equal( twoNativeLibraryPath, resolver.ResolveUnmanagedDllToPath("Two")); } }
private void ValidateNativeLibraryResolutions( string nativeLibraryPaths, string expectedResolvedFilePath, string lookupName, OS resolvesOnOSes) { using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", $"{nativeLibraryPaths}", "")) { AssemblyDependencyResolver resolver = new AssemblyDependencyResolver( Path.Combine(TestBasePath, _componentAssemblyPath)); string result = resolver.ResolveUnmanagedDllToPath(lookupName); if (OperatingSystem.IsWindows()) { if (resolvesOnOSes.HasFlag(OS.Windows)) { Assert.Equal(expectedResolvedFilePath, result); } else { Assert.Null(result); } } else if (OperatingSystem.IsMacOS()) { if (resolvesOnOSes.HasFlag(OS.OSX)) { Assert.Equal(expectedResolvedFilePath, result); } else { Assert.Null(result); } } else { if (resolvesOnOSes.HasFlag(OS.Linux)) { Assert.Equal(expectedResolvedFilePath, result); } else { Assert.Null(result); } } } }
public void TestSingleNativeDependency() { string nativeLibraryPath = CreateMockStandardNativeLibrary("native", "Single"); using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( 0, "", Path.GetDirectoryName(nativeLibraryPath), "")) { AssemblyDependencyResolver resolver = new AssemblyDependencyResolver( Path.Combine(TestBasePath, _componentAssemblyPath)); Assert.Equal( nativeLibraryPath, resolver.ResolveUnmanagedDllToPath("Single")); } }