Inheritance: IRegistry
Beispiel #1
0
        public void Simulate01() {
            var tr = new RegistryMock(SimulateRegistry01());

            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);

            var ri = new RInstallation(tr, fs);
            var svl = new SupportedRVersionRange(3, 2, 3, 2);

            var engines = ri.GetCompatibleEngines(svl);
            engines.Should().NotBeEmpty();

            var e = engines.FirstOrDefault();
            e.VerifyInstallation(svl, fs).Should().BeTrue();
            
            e.Version.Major.Should().BeGreaterOrEqualTo(3);
            e.Version.Minor.Should().BeGreaterOrEqualTo(2);
            e.InstallPath.Should().StartWithEquivalent(@"C:\Program Files");
            e.InstallPath.Should().Contain("R-");
            e.Version.Should().Be(new Version(3, 2, 3));
        }
Beispiel #2
0
        public void MsRClient() {
            var rClientInstallPath = @"C:\Program Files\Microsoft\R Client\";
            var rClientRPath = @"C:\Program Files\Microsoft\R Client\R_SERVER\";
            var tr = new RegistryMock(SimulateRegistryMsRClient(rClientInstallPath, rClientRPath));

            SqlRClientInstallation.GetRClientPath(tr).Should().Be(rClientRPath);

            var shell = Substitute.For<ICoreShell>();
            shell.ShowMessage(Arg.Any<string>(), Arg.Any<MessageButtons>()).Returns(MessageButtons.Yes);
            shell.MainThread.Returns(Thread.CurrentThread);

            MicrosoftRClient.CheckMicrosoftRClientInstall(shell, tr);
            shell.Received(1).ShowMessage(Arg.Any<string>(), Arg.Any<MessageButtons>());

            MicrosoftRClient.CheckMicrosoftRClientInstall(shell);
            shell.Received(1).ShowMessage(Arg.Any<string>(), Arg.Any<MessageButtons>());
        }
Beispiel #3
0
        public void IncompatibleVerson01() {
            var tr = new RegistryMock(SimulateRegistry02());
            var svl = new SupportedRVersionRange(3, 2, 3, 9);
            var fs = Substitute.For<IFileSystem>();
            var ri = new RInstallation(tr, fs);

            ri.GetCompatibleEngines(svl).Should().BeEmpty();

            string dir = @"C:\Program Files\RRO\R-3.1.3";
            var fsi = Substitute.For<IFileSystemInfo>();
            fsi.Attributes.Returns(FileAttributes.Directory);
            fsi.FullName.Returns(dir);
            fs.GetDirectoryInfo(@"C:\Program Files\RRO").EnumerateFileSystemInfos().Returns(new[] { fsi });
            
            ri = new RInstallation(tr, fs);
            var engines = ri.GetCompatibleEngines(svl);
            engines.Should().BeEmpty();
        }
Beispiel #4
0
        public void Duplicates() {
            var tr = new RegistryMock(SimulateDuplicates());
            var svl = new SupportedRVersionRange(3, 2, 3, 4);

            string dir = @"C:\Program Files\Microsoft\R Client\R_SERVER";
            var fs = Substitute.For<IFileSystem>();
            var fsi = Substitute.For<IFileSystemInfo>();
            fsi.Attributes.Returns(FileAttributes.Directory);
            fsi.FullName.Returns(dir);
            fs.GetDirectoryInfo(@"C:\Program Files\Microsoft\R Client\R_SERVER").EnumerateFileSystemInfos().Returns(new IFileSystemInfo[] { fsi });

            var fvi = SimulateFileVersion(3, 22);
            fs.GetVersionInfo(Path.Combine(dir, @"bin\x64", "R.dll")).Returns(fvi);

            PretendRFilesAvailable(fs, dir);
            var ri = new RInstallation(tr, fs);

            var engines = ri.GetCompatibleEngines(svl);
            engines.Should().HaveCount(1);

            var e = engines.First();
            e.Name.Should().Contain("Microsoft R");
            e = new RInterpreterInfo(e.Name, e.InstallPath, fs);
        }
Beispiel #5
0
        public void MissingBinaries() {
            var tr = new RegistryMock(SimulateRegistry02());
            var svl = new SupportedRVersionRange(3, 1, 3, 4);

            string dir = @"C:\Program Files\R\R-3.1.3";
            var fs = Substitute.For<IFileSystem>();
            var fsi = Substitute.For<IFileSystemInfo>();
            fsi.Attributes.Returns(FileAttributes.Directory);
            fsi.FullName.Returns(dir);
            fs.GetDirectoryInfo(@"C:\Program Files\R").EnumerateFileSystemInfos().Returns(new IFileSystemInfo[] { fsi });

            var fvi = SimulateFileVersion(3, 13);
            fs.GetVersionInfo(Path.Combine(dir, @"bin\x64", "R.dll")).Returns(fvi);

            PretendRFilesAvailable(fs, dir);
            var ri = new RInstallation(tr, fs);

            var e = ri.GetCompatibleEngines(svl).FirstOrDefault();
            e.Should().NotBeNull();

            e = new RInterpreterInfo(e.Name, e.InstallPath, fs);
            var coreShell = Substitute.For<ICoreShell>();
            fs = Substitute.For<IFileSystem>();
            e.VerifyInstallation(svl, fs, coreShell).Should().BeFalse();

            coreShell.When(x => x.ShowMessage(Arg.Any<string>(), MessageButtons.OK)).Do(x => {
                var s = x.Args()[0] as string;
                s.Should().Contain("Cannot find");
            });
            coreShell.Received().ShowMessage(Arg.Any<string>(), MessageButtons.OK);
        }
Beispiel #6
0
        public void IncompatibleVersonInPF() {
            var tr = new RegistryMock(SimulateRegistry02());
            var svl = new SupportedRVersionRange(3, 1, 3, 9);

            var root = @"C:\Program Files\R";
            string dir = Path.Combine(root, "R-3.1.3");
            var fs = Substitute.For<IFileSystem>();
            fs.DirectoryExists(root).Returns(true);
            fs.DirectoryExists(dir).Returns(true);

            var fsi = Substitute.For<IFileSystemInfo>();
            fsi.Attributes.Returns(FileAttributes.Directory);
            fsi.FullName.Returns(dir);
            fs.GetDirectoryInfo(root).EnumerateFileSystemInfos().Returns(new IFileSystemInfo[] { fsi });

            var ri = new RInstallation(tr, fs);
            var engines = ri.GetCompatibleEngines(svl);
            engines.Should().BeEmpty();
        }