Beispiel #1
0
        public void RInstallation_Test03()
        {
            var tr = new RegistryMock(SimulateRegistry03());

            RInstallation.Registry = tr;

            string dir   = @"C:\Program Files\MRO\R-3.2.3";
            string dir64 = dir + @"\bin\x64\";
            var    fs    = Substitute.For <IFileSystem>();

            PretendRFilesAvailable(fs, dir);

            var fvi = Substitute.For <IFileVersionInfo>();

            fvi.FileMajorPart.Returns(3);
            fvi.FileMinorPart.Returns(23);
            fs.GetVersionInfo(dir64 + "R.dll").Returns(fvi);

            RInstallation.FileSystem = fs;
            RInstallData data = RInstallation.GetInstallationData(null, 3, 2, 3, 2);

            data.Status.Should().Be(RInstallStatus.OK);
            data.Version.Major.Should().BeGreaterOrEqualTo(3);
            data.Version.Minor.Should().BeGreaterOrEqualTo(2);
            data.Path.Should().StartWithEquivalent(@"C:\Program Files");
            data.Path.Should().Contain("R-");
            data.Version.Should().Be(new Version(3, 2, 3));
        }
Beispiel #2
0
        // TODO: this probably needs configuration file
        // or another dynamic source of supported versions.

        public static bool VerifyRIsInstalled(string path, bool showErrors)
        {
            RInstallData data = RInstallation.GetInstallationData(path,
                                                                  SupportedRVersionList.MinMajorVersion, SupportedRVersionList.MinMinorVersion,
                                                                  SupportedRVersionList.MaxMajorVersion, SupportedRVersionList.MaxMinorVersion);

            if (data.Status != RInstallStatus.OK)
            {
                if (showErrors)
                {
                    string message = FormatMessage(data);
                    VsAppShell.Current.ShowErrorMessage(message);
                    if (data.Status == RInstallStatus.PathNotSpecified || data.Status == RInstallStatus.UnsupportedVersion)
                    {
                        if (!string.IsNullOrEmpty(path))
                        {
                            // If path is in Tools | Options and yet we can't find proper R
                            // we need to clear this setting.
                            RToolsSettings.Current.RBasePath = null;
                        }
                        RInstallation.GoToRInstallPage();
                    }
                }
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        public void RInstallation_Test04()
        {
            var tr = new RegistryMock(SimulateRegistry04());

            RInstallation.Registry = tr;

            RInstallation.GetCompatibleEnginePathFromRegistry().Should().BeNullOrEmpty();

            string dir = @"C:\Program Files\RRO\R-3.1.3";
            var    fs  = Substitute.For <IFileSystem>();
            var    fsi = Substitute.For <IFileSystemInfo>();

            fsi.Attributes.Returns(System.IO.FileAttributes.Directory);
            fsi.FullName.Returns(dir);
            fs.GetDirectoryInfo(@"C:\Program Files\RRO").EnumerateFileSystemInfos().Returns(new IFileSystemInfo[] { fsi });
            RInstallation.FileSystem = fs;

            RInstallData data = RInstallation.GetInstallationData(null, 3, 2, 3, 2);

            data.Status.Should().Be(RInstallStatus.PathNotSpecified);

            PretendRFilesAvailable(fs, dir);
            data = RInstallation.GetInstallationData(dir, 3, 2, 3, 2);
            data.Status.Should().Be(RInstallStatus.UnsupportedVersion);
        }
Beispiel #4
0
        private static string FormatMessage(RInstallData data)
        {
            Debug.Assert(data.Status != RInstallStatus.OK);

            switch (data.Status)
            {
            case RInstallStatus.UnsupportedVersion:
                return(string.Format(CultureInfo.InvariantCulture, Resources.Error_UnsupportedRVersion,
                                     data.Version.Major, data.Version.Minor, data.Version.Build,
                                     SupportedRVersionList.MinMajorVersion, SupportedRVersionList.MinMinorVersion, "*",
                                     SupportedRVersionList.MaxMajorVersion, SupportedRVersionList.MaxMinorVersion, "*"));

            case RInstallStatus.ExceptionAccessingPath:
                return(string.Format(CultureInfo.InvariantCulture, Resources.Error_ExceptionAccessingPath, data.Path, data.Exception.Message));

            case RInstallStatus.NoRBinaries:
                Debug.Assert(!string.IsNullOrEmpty(data.Path));
                return(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotFindRBinariesFormat, data.BinPath));

            case RInstallStatus.PathNotSpecified:
                return(string.Format(CultureInfo.InvariantCulture, Resources.Error_UnableToFindR, Environment.NewLine + Environment.NewLine));
            }

            return(string.Empty);
        }
Beispiel #5
0
        public void Test01()
        {
            var          svl  = new SupportedRVersionRange(0, 0, 0, 0);
            RInstallData data = RInstallation.GetInstallationData(null, svl);

            data.Status.Should().BeEither(RInstallStatus.PathNotSpecified, RInstallStatus.UnsupportedVersion);
        }
Beispiel #6
0
        public static ActionResult MROInstallPromptAction(Session session)
        {
            ActionResult actionResult = ActionResult.Success;
            DialogResult ds           = DialogResult.No;

            session.Log("Begin R detection action");
            session["InstallMRO"] = "No";

            RInstallData data = RInstallation.GetInstallationData(null,
                                                                  SupportedRVersionList.MinMajorVersion, SupportedRVersionList.MinMinorVersion,
                                                                  SupportedRVersionList.MaxMajorVersion, SupportedRVersionList.MaxMinorVersion);

            if (data.Status != RInstallStatus.OK)
            {
                using (var form = new InstallMROForm()) {
                    ds = form.ShowDialog(new SetupWindowHandle());
                }
            }

            if (ds == DialogResult.Yes)
            {
                session["InstallMRO"] = "Yes";
                RInstallation.GoToRInstallPage();
            }

            session.Log("End R detection action");
            return(actionResult);
        }
Beispiel #7
0
        public void InstallPackages_BaseTest()
        {
            var          svl  = new SupportedRVersionRange(3, 2, 3, 2);
            RInstallData data = RInstallation.GetInstallationData(string.Empty, svl);

            data.Status.Should().Be(RInstallStatus.OK);
            bool result = InstallPackages.IsInstalled("base", Int32.MaxValue, data.Path);

            result.Should().BeTrue();
        }
Beispiel #8
0
        public void InstallPackages_BaseTest()
        {
            RInstallData data = RInstallation.GetInstallationData(string.Empty,
                                                                  SupportedRVersionList.MinMajorVersion, SupportedRVersionList.MinMinorVersion,
                                                                  SupportedRVersionList.MaxMajorVersion, SupportedRVersionList.MaxMinorVersion);

            data.Status.Should().Be(RInstallStatus.OK);
            bool result = InstallPackages.IsInstalled("base", Int32.MaxValue, data.Path);

            result.Should().BeTrue();
        }
Beispiel #9
0
        public void Test02()
        {
            // Use actual files and registry
            var          ri   = new RInstallation();
            var          svl  = new SupportedRVersionRange(3, 2, 3, 9);
            RInstallData data = ri.GetInstallationData(null, svl);

            data.Status.Should().Be(RInstallStatus.OK);
            data.Version.Major.Should().BeGreaterOrEqualTo(3);
            data.Version.Minor.Should().BeGreaterOrEqualTo(2);
            string path = Path.Combine(data.Path, @"bin\x64");

            Directory.Exists(path).Should().BeTrue();
        }
Beispiel #10
0
        public void RInstallation_Test02()
        {
            // Use actual files and registry
            RInstallation.Registry   = null;
            RInstallation.FileSystem = null;

            RInstallData data = RInstallation.GetInstallationData(null, 3, 2, 3, 2);

            data.Status.Should().Be(RInstallStatus.OK);
            data.Version.Major.Should().BeGreaterOrEqualTo(3);
            data.Version.Minor.Should().BeGreaterOrEqualTo(2);
            string path = Path.Combine(data.Path, @"bin\x64");

            Directory.Exists(path).Should().BeTrue();
        }
Beispiel #11
0
        public void Test05()
        {
            var tr = new RegistryMock(SimulateRegistry04());

            string dir = @"C:\Program Files\RRO\R-3.1.3";
            var    fs  = Substitute.For <IFileSystem>();

            PretendRFilesAvailable(fs, dir);

            var fvi = Substitute.For <IFileVersionInfo>();

            fvi.FileMajorPart.Returns(3);
            fvi.FileMinorPart.Returns(13);
            fs.GetVersionInfo(dir + "R.dll").Returns(fvi);

            var          ri   = new RInstallation(tr, fs);
            var          svl  = new SupportedRVersionRange(3, 2, 3, 2);
            RInstallData data = ri.GetInstallationData(dir, svl);

            data.Status.Should().Be(RInstallStatus.UnsupportedVersion);
        }
Beispiel #12
0
        public void RInstallation_Test01()
        {
            RInstallData data = RInstallation.GetInstallationData(null, 0, 0, 0, 0);

            data.Status.Should().BeEither(RInstallStatus.PathNotSpecified, RInstallStatus.UnsupportedVersion);
        }