Exemplo n.º 1
0
        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); });
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// if the parameter is null or empty string, return the default names of the R shared library file depending on the platform
 /// </summary>
 /// <param name="dll">The name of the library provided, possibly null or empty</param>
 /// <returns>A candidate for the file name of the R shared library</returns>
 protected static string ProcessRDllFileName(string dll)
 {
     if (!string.IsNullOrEmpty(dll))
     {
         return(dll);
     }
     return(NativeUtility.GetRLibraryFileName());
 }
Exemplo n.º 3
0
        public void TestFindRBinPath()
        {
            string rLibPath = createTestRegistryUtil().FindRPath();
            var    files    = Directory.GetFiles(rLibPath);
            var    fnmatch  = files.Where(fn => fn.ToLower() == Path.Combine(rLibPath.ToLower(), NativeUtility.GetRLibraryFileName().ToLower()));

            Assert.Equal(1, fnmatch.Count());
        }
Exemplo n.º 4
0
 private static string getRDllName()
 {
     return(NativeUtility.GetRLibraryFileName());
 }