Beispiel #1
0
        public async Task <string> GenerateOutput(Guid testId, GenerateOutputBindingModel model)
        {
            var test = await GetTestAsync(testId);

            var testExePath = _paths.TestsData.Execs[test.Name].MainExePaths.Absolute;

            var processStartInfo = new ProcessStartInfo(testExePath)
            {
                RedirectStandardOutput = true,
                RedirectStandardInput  = true,
                RedirectStandardError  = true,
                WindowStyle            = ProcessWindowStyle.Hidden,
                CreateNoWindow         = true
            };

            var process = Process.Start(processStartInfo);

            await process.StandardInput.WriteAsync(model.Input);

            await process.StandardInput.FlushAsync();

            var output = await process.StandardOutput.ReadToEndAsync();

            if (!process.HasExited)
            {
                process.Kill();
            }

            return(output);
        }
Beispiel #2
0
 public async Task <string> GenerateOutputAsync([FromRoute] Guid testId, [FromBody] GenerateOutputBindingModel model)
 {
     return(await _testsService.GenerateOutput(testId, model));
 }