public void Fail() { var processRunner = new LoggingProcessRunner <LoggingProcessRunnerTests>(new ProcessRunner(), mockup.Get <ILogger <LoggingProcessRunnerTests> >()); var startInfo = new ProcessStartInfo("pwsh", "asdfasdfdsa"); var result = processRunner.Run(startInfo); Assert.Equal(64, result); }
public void EchoError() { var processRunner = new LoggingProcessRunner <LoggingProcessRunnerTests>(new ProcessRunner(), mockup.Get <ILogger <LoggingProcessRunnerTests> >()); var startInfo = new ProcessStartInfo("pwsh", "-c Write-Error 'hi'"); var result = processRunner.Run(startInfo); Assert.Equal(1, result); }
private static IProcessRunner CreateRunner(IServiceProvider s, ThreaxProcessHelperOptions options) { IProcessRunner runner = new ProcessRunner(); if (options.IncludeLogOutput) { try { var logger = s.GetRequiredService <ILogger <DefaultLog> >(); runner = new LoggingProcessRunner <DefaultLog>(runner, logger); } catch (ObjectDisposedException) { //Sometimes this is called after the context is disposed. //If that happens it is ok, logging will not be included. } } if (options.DecorateProcessRunner != null) { runner = options.DecorateProcessRunner.Invoke(runner); } return(runner); }