public void Launch(int outputCount, int delayMilliseconds) { var path = this.testProcessPath.Value; var expected = Math.Max(outputCount, 0); var parserCallCount = 0; var processorCallCount = 0; path.Should().NotBeNullOrEmpty("because the test executable is required to verify launching the process."); UnderTest.ProcessManager.OutputParser outputParser = output => { ++parserCallCount; return Enumerable.Empty<UnderTest.DisplaySegment>(); }; UnderTest.ProcessManager.DisplaySegmentProcessor segmentProcessor = segments => { ++processorCallCount; }; UnderTest.ProcessManager.Launch(path, String.Format("{0} {1}", outputCount, delayMilliseconds), Path.GetDirectoryName(path), segmentProcessor, outputParser); parserCallCount.Should().Be(expected, "because the parser should be called once per write to stdout."); processorCallCount.Should().Be(expected, "because the parser should be called once per write to stdout."); }
public void LaunchWithOutputInvokesTheParserAndProcessor() { var path = this.testProcessPath.Value; var parserCalled = false; var processorCalled = false; path.Should().NotBeNullOrEmpty("because the test executable is required to verify launching the process."); UnderTest.ProcessManager.OutputParser outputParser = output => { parserCalled = true; return Enumerable.Empty<UnderTest.DisplaySegment>(); }; UnderTest.ProcessManager.DisplaySegmentProcessor segmentProcessor = segments => { processorCalled = true; }; UnderTest.ProcessManager.Launch(path, "1", Path.GetDirectoryName(path), segmentProcessor, outputParser); parserCalled.Should().BeTrue("because output was generated."); processorCalled.Should().BeTrue("because output was generated."); }