public void TestLoadWindows() { // Test, if possible, loading 32 bits R.dll from a 64 bits process. // I do not really like tests to be platform-dependent, but this is pragmatically unavoidable. if (Environment.OSVersion.Platform != PlatformID.Win32NT) { return; } string rDllPath = ""; try { rDllPath = new NativeUtility().FindRPathFromRegistry(); } catch (ApplicationException) // registry keys not found - bail out { return; } if (Environment.Is64BitProcess) { if (!rDllPath.Contains("x64")) // Odd, but not what we are testing here. { return; } rDllPath = rDllPath.Replace("x64", "i386"); var rDllFullFilePath = Path.Combine(rDllPath, NativeUtility.GetRLibraryFileName()); if (!File.Exists(rDllFullFilePath)) { return; } Assert.Throws <ArgumentException>(() => { var lib = new MockLoadLib(rDllFullFilePath); }); } }
public static void TestFindRPath(string expectContains) { var rPath = new NativeUtility().FindRPath(); var match = rPath.Contains(expectContains); Console.WriteLine("Detected RPath is {0}", rPath); if (match) { Console.WriteLine("Contains string '{0}' as expected", expectContains); } else { Console.WriteLine("Does NOT contain string '{0}' as expected", expectContains); } }