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); }
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)); }
public void 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; var svl = new SupportedRVersionRange(3, 2, 3, 2); RInstallData data = RInstallation.GetInstallationData(null, svl); 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)); }
public void Test04() { var tr = new RegistryMock(SimulateRegistry04()); RInstallation.Registry = tr; var svl = new SupportedRVersionRange(3, 2, 3, 9); RInstallation.GetCompatibleEnginePathFromRegistry(svl).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, svl); data.Status.Should().Be(RInstallStatus.PathNotSpecified); PretendRFilesAvailable(fs, dir); data = RInstallation.GetInstallationData(dir, svl); data.Status.Should().Be(RInstallStatus.UnsupportedVersion); }
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>()); }
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(); }
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); }
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 = new Version(3, 13); fs.GetFileVersion(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(); var ui = Substitute.For <IUIService>(); fs = Substitute.For <IFileSystem>(); var coreShell = Substitute.For <ICoreShell>(); coreShell.UI().Returns(ui); e = new RInterpreterInfo(e.Name, e.InstallPath, fs); e.VerifyInstallation(svl, fs, ui).Should().BeFalse(); ui.When(x => x.ShowMessage(Arg.Any <string>(), MessageButtons.OK)).Do(x => { var s = x.Args()[0] as string; s.Should().Contain("Cannot find"); }); ui.Received().ShowMessage(Arg.Any <string>(), MessageButtons.OK); }
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(); }