Esempio n. 1
0
File: E2ETest.cs Progetto: genlu/cli
    private static void Forward(int bufferSize, ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites)
    {
        var forwarder = new StreamForwarder(bufferSize);
        var writes    = new List <string>();

        if ((options & ForwardOptions.WriteLine) != 0)
        {
            forwarder.ForwardTo(
                write: (options & ForwardOptions.Write) == 0 ? (Action <string>)null : writes.Add,
                writeLine: s => writes.Add(s + "\n"));
        }
        if ((options & ForwardOptions.Capture) != 0)
        {
            forwarder.Capture();
        }
        forwarder.Read(new StringReader(str));
        Assert.Equal(expectedWrites, writes);
        var captured = forwarder.GetCapturedOutput();

        Assert.Equal(expectedCaptured, captured);
    }
Esempio n. 2
0
        private void TestCapturingAndForwardingHelper(ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites)
        {
            var forwarder = new StreamForwarder();
            var writes    = new List <string>();

            if ((options & ForwardOptions.WriteLine) != 0)
            {
                forwarder.ForwardTo(writeLine: s => writes.Add(s + Environment.NewLine));
            }
            if ((options & ForwardOptions.Capture) != 0)
            {
                forwarder.Capture();
            }

            forwarder.Read(new StringReader(str));
            Assert.Equal(expectedWrites, writes);

            var captured = forwarder.CapturedOutput;

            Assert.Equal(expectedCaptured, captured);
        }