public void GetBestGhostscriptInstance_WithInternalAndNoRegistryInstance_ReturnsInternalInstance() { const string appPath = @"C:\MyApp"; const string gsPath = appPath + @"\Ghostscript"; const string gsExe = gsPath + @"\Bin\gswin32c.exe"; _fileMock.Stub(x => x.Exists(gsExe)).Return(true); GhostscriptDiscovery ghostscriptDiscovery = CreateGhostscriptDiscoveryWithMocks(appPath); var gs = ghostscriptDiscovery.GetBestGhostscriptInstance("9.10"); Assert.AreEqual("<internal>", gs.Version); }
public void GetBestGhostscriptInstance_WithNoGhostscriptRegistryKey_ReturnsNull() { var hklm = MockRepository.GenerateStub <IRegistryKey>(); _registryMock.Stub(x => x.LocalMachine).Return(hklm); GhostscriptDiscovery ghostscriptDiscovery = CreateGhostscriptDiscoveryWithMocks(); hklm.Stub(x => x.OpenSubKey(ghostscriptDiscovery.RegistryPath)).Return(null); var gs = ghostscriptDiscovery.GetBestGhostscriptInstance("9.10"); Assert.IsNull(gs); }
public void GetBestGhostscriptInstance_WhenExceptionIsThrownInRegistry_ReturnsNull() { var hklm = MockRepository.GenerateStub <IRegistryKey>(); _registryMock.Stub(x => x.LocalMachine).Return(hklm); GhostscriptDiscovery ghostscriptDiscovery = CreateGhostscriptDiscoveryWithMocks(); AddGhostscriptVersionsWithException(new[] { "9.15" }, ghostscriptDiscovery.RegistryPath, _fileMock, hklm); var gs = ghostscriptDiscovery.GetBestGhostscriptInstance("9.10"); Assert.IsNull(gs); }
public void GetBestGhostscriptInstance_WithoutParameter_ReturnsDefaultVersion() { var hklm = MockRepository.GenerateStub <IRegistryKey>(); _registryMock.Stub(x => x.LocalMachine).Return(hklm); GhostscriptDiscovery ghostscriptDiscovery = CreateGhostscriptDiscoveryWithMocks(); AddGhostscriptVersions(new[] { "9.14", "9.10" }, ghostscriptDiscovery.RegistryPath, _fileMock, hklm); var gs = ghostscriptDiscovery.GetBestGhostscriptInstance(); Assert.AreEqual(GhostscriptDiscovery.GhostscriptVersion, gs.Version); }
public void GetBestGhostscriptInstance_WithUnsupportedRegistryInstances_ReturnsNull() { var hklm = MockRepository.GenerateStub <IRegistryKey>(); _registryMock.Stub(x => x.LocalMachine).Return(hklm); GhostscriptDiscovery ghostscriptDiscovery = CreateGhostscriptDiscoveryWithMocks(); AddGhostscriptVersions(new[] { "9.14", "9.15" }, ghostscriptDiscovery.RegistryPath, _fileMock, hklm); var gs = ghostscriptDiscovery.GetBestGhostscriptInstance("9.20"); Assert.IsNull(gs); }
public void GetBestGhostscriptInstance_WithMultipleRegistryInstances_ReturnsGivenRegistryInstance(string gsVersion) { var hklm = MockRepository.GenerateStub <IRegistryKey>(); _registryMock.Stub(x => x.LocalMachine).Return(hklm); GhostscriptDiscovery ghostscriptDiscovery = CreateGhostscriptDiscoveryWithMocks(); AddGhostscriptVersions(new[] { "9.14", "9.15" }, ghostscriptDiscovery.RegistryPath, _fileMock, hklm); var gs = ghostscriptDiscovery.GetBestGhostscriptInstance(gsVersion); Assert.AreEqual(gsVersion, gs.Version); }
public void GetBestGhostscriptInstance_WithInternalAndRegistryInstance_ReturnsInternalInstance() { const string appPath = @"C:\MyApp"; const string gsPath = appPath + @"\Ghostscript"; const string gsExe = gsPath + @"\Bin\gswin32c.exe"; var hklm = MockRepository.GenerateStub <IRegistryKey>(); _registryMock.Stub(x => x.LocalMachine).Return(hklm); _fileMock.Stub(x => x.Exists(gsExe)).Return(true); GhostscriptDiscovery ghostscriptDiscovery = CreateGhostscriptDiscoveryWithMocks(appPath); AddGhostscriptVersions(new [] { "9.15" }, ghostscriptDiscovery.RegistryPath, _fileMock, hklm); var gs = ghostscriptDiscovery.GetBestGhostscriptInstance("9.10"); Assert.AreEqual("<internal>", gs.Version); }