Esempio n. 1
0
        public async Task RunAndWaitForScript_NormalUsecase_everythingOk()
        {
            (int exitCode, List <string> stdoutLines, List <string> stderrLines) = await
                                                                                   _scriptRunner.RunAndWaitForScript(
                scriptName : TEST_SCRIPT_FOR_RUN,
                scriptArgs : string.Join(" ", TEST_SCRIPT_ARGS),
                stdin :      TEST_SCRIPT_STDIN
                );

            Assert.True(exitCode == TEST_SCRIPT_EXITCODE);

            // The testscript writes the first two arguments to stdout
            Assert.AreEqual(stdoutLines[0], TEST_SCRIPT_ARGS[0]);
            Assert.AreEqual(stdoutLines[1], TEST_SCRIPT_ARGS[1]);

            // The testsript writes the third and fourth argument to stderr
            Assert.AreEqual(stderrLines[0], TEST_SCRIPT_ARGS[2]);
            Assert.AreEqual(stderrLines[1], TEST_SCRIPT_ARGS[3]);
        }
Esempio n. 2
0
        /// <summary>
        /// Runs the script 'manageScreenResolutions' on the remote computer.
        /// </summary>
        /// <param name="scriptArgs">
        /// The command-line-arguments passed to the script
        /// </param>
        /// <param name="timeoutMillis">
        /// The maximum time to wait until the script returns  in milliseconds.
        /// </param>
        /// <returns>
        /// The lines written to stdout by the script.
        /// </returns>
        private async Task <List <string> > runRemoteManageScreenResolutionsScript(
            string scriptArgs)
        {
            // if an exception occurs, let it handle the caller
            int           exitCode;
            List <string> stdoutLines;
            List <string> stderrLines;

            (exitCode, stdoutLines, stderrLines) = await _remoteScriptRunner.RunAndWaitForScript(
                _scriptNameManageScreenResolutions, scriptArgs);

            if (exitCode != 0)
            {
                string msg = $"Remote script returned with exit-code {exitCode}: '{_scriptNameManageScreenResolutions} {scriptArgs}'. Standard-error-outut: '{string.Join(';', stderrLines)}'";
                _logger?.LogError(msg);
                throw new WDException(msg);
            }

            return(stdoutLines);
        }