Example #1
0
        private static DirectoryPath GetInstallLocation(bool is64Bit, InnoSetupVersion version)
        {
            var programFiles = is64Bit ? "/Program Files (x86)/" : "/Program Files/";

            switch (version)
            {
            case InnoSetupVersion.InnoSetup6:
                return($@"{programFiles}Inno Setup 6");

            case InnoSetupVersion.InnoSetup5:
                return($@"{programFiles}Inno Setup 5");

            default:
                return(null);
            }
        }
Example #2
0
        private static string GetRegistryKeyPath(bool is64Bit, InnoSetupVersion version)
        {
            var softwareKeyPath = is64Bit ? @"SOFTWARE\Wow6432Node\" : @"SOFTWARE\";

            switch (version)
            {
            case InnoSetupVersion.InnoSetup6:
                return($@"{softwareKeyPath}Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1");

            case InnoSetupVersion.InnoSetup5:
                return($@"{softwareKeyPath}Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1");

            default:
                return(null);
            }
        }
        private string GetRegistryKeyPathForVersion(InnoSetupVersion version)
        {
            // On 64-bit Windows, the registry key for Inno Setup will be accessible under Wow6432Node
            var softwareKeyPath = _environment.Platform.Is64Bit ? @"SOFTWARE\Wow6432Node\" : @"SOFTWARE\";

            switch (version)
            {
            case InnoSetupVersion.InnoSetup6:
                return($@"{softwareKeyPath}Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1");

            case InnoSetupVersion.InnoSetup5:
                return($@"{softwareKeyPath}Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1");

            default:
                throw new ArgumentOutOfRangeException(nameof(version), version, "Missing switch case");
            }
        }
Example #4
0
        private void ConfigureInstalledLocation(bool is64Bit, InnoSetupVersion version)
        {
            var registryKeyPath = GetRegistryKeyPath(is64Bit, version);
            var installLocation = GetInstallLocation(is64Bit, version);

            var installedToolPath = installLocation.CombineWithFilePath("iscc.exe");

            InstalledToolPaths.Add(version, installLocation.CombineWithFilePath("iscc.exe"));

            var innoSetupKey = Substitute.For <IRegistryKey>();

            innoSetupKey.GetValue("InstallLocation").Returns(installLocation.FullPath);

            Registry.LocalMachine.OpenKey(registryKeyPath).Returns(innoSetupKey);

            FileSystem.CreateDirectory(installLocation);
            FileSystem.CreateFile(installedToolPath);
        }
            public void Should_Use_Provided_InnoSetup_Version_When_Tool_Path_Is_Not_Provided(bool is64Bit, InnoSetupVersion version)
            {
                // Given
                var fixture = new InnoSetupFixture();

                fixture.GivenDefaultToolDoNotExist();
                fixture.GivenToolIsInstalled(is64Bit, InnoSetupVersion.InnoSetup5);
                fixture.GivenToolIsInstalled(is64Bit, InnoSetupVersion.InnoSetup6);
                fixture.Settings.Version = version;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal(fixture.InstalledToolPaths[version].FullPath, result.Path.FullPath);
            }
            public void Should_Find_InnoSetup_Runner_In_Installation_Path_If_Tool_Path_Not_Provided(bool is64Bit, InnoSetupVersion version)
            {
                // Given
                var fixture = new InnoSetupFixture();

                fixture.GivenDefaultToolDoNotExist();
                fixture.GivenToolIsInstalled(is64Bit, version);

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal(fixture.InstalledToolPaths[version].FullPath, result.Path.FullPath);
            }
Example #7
0
 public void GivenToolIsInstalled(bool is64Bit, InnoSetupVersion version)
 {
     Environment.Platform.Is64Bit = is64Bit;
     ConfigureInstalledLocation(is64Bit, version);
 }