public void ExternalTool_WithStandardOutputAndStandardErrorContents_BothOutputStreamsAreWrittenToFile() { const string canary1 = "se5sm85"; const string canary2 = "ze5vb75"; var outputFile = Path.GetTempFileName(); // Need to do this the long way around to avoid consuming the result. var result = new ExternalTool { ExecutablePath = TestData.CommandHandler, Arguments = TestData.MakeCommandString(string.Format("echo {0} & {1}", canary1, canary2)), OutputFilePath = outputFile }.Start().GetResult(ExecuteTimeout); // Just for debug info. result.ForwardOutputs(); try { Assert.AreNotEqual(0, result.ExitCode); Assert.IsTrue(result.StandardOutput.Contains(canary1)); Assert.IsTrue(result.StandardError.Contains(canary2)); var outputFileContents = File.ReadAllText(outputFile); Assert.IsTrue(outputFileContents.Contains(canary1)); Assert.IsTrue(outputFileContents.Contains(canary2)); } finally { File.Delete(outputFile); } }
public void ExternalTool_StandardErrorIsCaptured() { const string canary = "26usgnffff"; // Need to do this the long way around to avoid consuming the result. var result = new ExternalTool { ExecutablePath = TestData.CommandHandler, Arguments = TestData.MakeCommandString(canary) // Nonsense command, should result in error. }.Start().GetResult(ExecuteTimeout); // Just for debug info. result.ForwardOutputs(); Assert.AreNotEqual(0, result.ExitCode); Assert.IsTrue(result.StandardError.Contains(canary)); }