Example #1
0
        public static int Main()
        {
            var tessCase = TestBinary.TestCaseArguments("ControlC");
            var process  = new ObservableProcess(tessCase);

            process.SubscribeLines(c =>
            {
                //if (c.Line.EndsWith("4"))
                {
                    process.SendControlC();
                }
                Console.WriteLine(c.Line);
            }, e => Console.Error.WriteLine(e));

            process.WaitForCompletion(TimeSpan.FromSeconds(20));
            return(0);
        }
Example #2
0
        [SkipOnNonWindowsFact] public void ControlCSend()
        {
            var args = TestCaseArguments(nameof(ControlC));

            args.SendControlCFirst = true;

            var process = new ObservableProcess(args);
            var seen    = new List <string>();

            process.SubscribeLines(c =>
            {
                seen.Add(c.Line);
                if (c.Line.Contains("before"))
                {
                    process.SendControlC();
                }
            });
            process.WaitForCompletion(TimeSpan.FromSeconds(1));

            seen.Should().NotBeEmpty().And.HaveCount(2, string.Join(Environment.NewLine, seen));
            seen[0].Should().Be("Written before control+c");
            seen[1].Should().Be("Written after control+c");
        }