public void SimpleInterspersed() { ProcessResult result = null; Assert.DoesNotThrow(() => { using (var process = new ProcessSpawnerWithSplitErrAndOut(TestApplications.SimpleInterspersedInfo)) { result = process.Run(); } }); Assert.NotNull(result); Assert.Equal(result.ExitCode, 3); Assert.GreaterThan(result.PeakPagedMemorySize, 0); Assert.GreaterThan(result.PeakVirtualMemorySize, 0); Assert.GreaterThan(result.PeakWorkingSet, 0); Assert.NotEqual(result.StartTime, DateTime.MinValue); Assert.NotEqual(result.ExitTime, DateTime.MinValue); Assert.GreaterThan(result.ExitTime - result.StartTime, TimeSpan.Zero); Assert.Null(result.FullBuffer); Assert.NotNull(result.FullOutput); Assert.NotNull(result.FullError); Assert.Equal(result.FullOutput, @"def def def def abcdef"); Assert.Equal(result.FullError, @"abc abc abc abc abcdef"); }
/// <summary> /// Executes the specified process. /// </summary> /// <returns>A <see cref="Test.ProcessResult" /> object representing the execution.</returns> public ProcessResult Run() { if (Exited) { throw new InvalidOperationException("Must not execute the process twice"); } if (Started) { throw new InvalidOperationException("Must not execute the process twice"); } AssociateEvents(); Started = true; var splitResult = m_split.Run(); var combinedResult = m_combined.Run(); Exited = true; return(ProduceResult(splitResult, combinedResult)); }
public void NakedInput() { ProcessResult result = null; Assert.DoesNotThrow(() => { using (var process = new ProcessSpawnerWithSplitErrAndOut(TestApplications.NakedInputInfo)) { process.OnInputRequested += (buf, writer) => { if (!string.IsNullOrEmpty(buf) && buf != "acb876") { Assert.Fail(); } writer.WriteLine("acb876"); return(ProcessInputHandleResult.Handled); }; result = process.Run(); } }); Assert.NotNull(result); Assert.NotNull(result.FullOutput); Assert.NotNull(result.FullError); Assert.Equal(result.FullOutput, @"acb876"); Assert.Equal(result.FullError, @""); }
public void PlusTwoNumber() { ProcessResult result = null; Assert.DoesNotThrow(() => { using (var process = new ProcessSpawnerWithSplitErrAndOut(TestApplications.PlusTwoNumberInfo)) { process.OnInputRequested += (buf, writer) => { if (string.IsNullOrEmpty(buf)) { return(ProcessInputHandleResult.Ignored); } if (buf == "878") { return(ProcessInputHandleResult.Ignored); } if (buf != "Please enter a number...") { Assert.Fail(); return(ProcessInputHandleResult.Ignored); } writer.WriteLine("876"); return(ProcessInputHandleResult.Handled); }; result = process.Run(); } }); Assert.NotNull(result); Assert.NotNull(result.FullOutput); Assert.NotNull(result.FullError); Assert.Equal(result.FullOutput, @"Please enter a number... 878"); Assert.Equal(result.FullError, @""); Assert.DoesNotThrow(() => { using (var process = new ProcessSpawnerWithSplitErrAndOut(TestApplications.PlusTwoNumberInfo)) { process.OnInputRequested += (buf, writer) => { if (string.IsNullOrEmpty(buf)) { return(ProcessInputHandleResult.Ignored); } if (buf == "Bad number") { return(ProcessInputHandleResult.Ignored); } if (buf != "Please enter a number...") { Assert.Fail(); return(ProcessInputHandleResult.Ignored); } writer.WriteLine("abc"); return(ProcessInputHandleResult.Handled); }; result = process.Run(); } }); Assert.NotNull(result); Assert.NotNull(result.FullOutput); Assert.NotNull(result.FullError); Assert.Equal(result.FullOutput, @"Please enter a number..."); Assert.Equal(result.FullError, @"Bad number"); }