Пример #1
0
    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.");
    }
Пример #2
0
    /// <summary>
    ///   Initializes a new instance of the <see cref="T:GoofyFoot.PhantomLauncher.UnitTests.ProcessManager"/> class.
    /// </summary>
    /// 
    public ProcessManager()
    {
      // Capture the private default output parser method for testing.  

      var methodInfo = typeof(UnderTest.ProcessManager).GetMethod("DefaultOutputParser", BindingFlags.NonPublic | BindingFlags.Static);
      this.defaultOutputParser = (UnderTest.ProcessManager.OutputParser)Delegate.CreateDelegate(typeof(UnderTest.ProcessManager.OutputParser), methodInfo);
    }
Пример #3
0
    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.");
    }