HpToolsLauncher.Helper.IsServiceTestInstalled C# (CSharp) Method

IsServiceTestInstalled() public static method

public static IsServiceTestInstalled ( ) : bool
return bool
        public static bool IsServiceTestInstalled()
        {
            RegistryKey regkey;
            string value;
            regkey = Registry.LocalMachine.OpenSubKey(ServiceTesCurrentVersionRegistryKey);
            if (regkey == null)
            {
                //try 64 bit
                regkey = Registry.LocalMachine.OpenSubKey(ServiceTesCurrentVersionWOW64RegistryKey);
            }

            if (regkey != null)
            {
                value = (string) regkey.GetValue(InstalltionFolderValue);
                if (!string.IsNullOrEmpty(value))
                {
                    return true;
                }
            }
            return false;
        }

Usage Example

        /// <summary>
        /// runs the given test
        /// </summary>
        /// <param name="testPath"></param>
        /// <param name="errorReason"></param>
        /// <param name="runCancelled">cancellation delegate, holds the function that checks cancellation</param>
        /// <returns></returns>
        public TestRunResults RunTest(string testPath, ref string errorReason, RunCancelledDelegate runCancelled)
        {
            TestRunResults runDesc = new TestRunResults();

            ConsoleWriter.ActiveTestRun = runDesc;
            ConsoleWriter.WriteLine(DateTime.Now.ToString(Launcher.DateFormat) + " Running: " + testPath);



            runDesc.ReportLocation = Helper.CreateTempDir();
            runDesc.ErrorDesc      = errorReason;
            runDesc.TestPath       = testPath;
            runDesc.TestState      = TestState.Unknown;
            if (!Helper.IsServiceTestInstalled())
            {
                runDesc.TestState = TestState.Error;
                runDesc.ErrorDesc = string.Format(Resources.LauncherStNotInstalled, System.Environment.MachineName);
                ConsoleWriter.WriteErrLine(runDesc.ErrorDesc);
                Environment.ExitCode = (int)Launcher.ExitCodeEnum.Failed;
                return(runDesc);
            }

            _runCancelled = runCancelled;
            if (!_stCanRun)
            {
                runDesc.TestState = TestState.Error;
                runDesc.ErrorDesc = Resources.STExecuterNotFound;
                return(runDesc);
            }
            string fileName = Path.Combine(_stExecuterPath, STRunnerName);

            if (!File.Exists(fileName))
            {
                runDesc.TestState = TestState.Error;
                runDesc.ErrorDesc = Resources.STExecuterNotFound;
                ConsoleWriter.WriteErrLine(Resources.STExecuterNotFound);
                return(runDesc);
            }

            Stopwatch s = Stopwatch.StartNew();

            runDesc.TestState = TestState.Running;
            if (!ExecuteProcess(fileName,
                                String.Format("{0} \"{1}\" {2} \"{3}\" ", STRunnerTestArg, testPath, STRunnerReportArg, runDesc.ReportLocation),
                                ref errorReason))
            {
                runDesc.TestState = TestState.Error;
                runDesc.ErrorDesc = errorReason;
                runDesc.Runtime   = s.Elapsed;
                return(runDesc);
            }
            else
            {
                runDesc.ReportLocation = Path.Combine(runDesc.ReportLocation, "Report");
            }

            runDesc.Runtime = s.Elapsed;
            return(runDesc);
        }
All Usage Examples Of HpToolsLauncher.Helper::IsServiceTestInstalled