Ejemplo n.º 1
0
        public void CombinedErrAndOutPlusTwoNumber()
        {
            ProcessResult result = null;

            Assert.DoesNotThrow(() => {
                using (var process = new ProcessSpawnerWithCombinedErrAndOut(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.Equal(result.FullOutput, @"Please enter a number...
878");

            Assert.DoesNotThrow(() => {
                using (var process = new ProcessSpawnerWithCombinedErrAndOut(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.Equal(result.FullOutput, @"Please enter a number...
Bad number");
        }
Ejemplo n.º 2
0
        public void CombinedAndSplitErrAndOutNakedInput()
        {
            ProcessResult result = null;

            Assert.DoesNotThrow(() => {
                using (var process = new ProcessSpawnerWithCombinedAndSplitErrAndOut(TestApplications.NakedInput)) {
                    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.FullStd);
            Assert.NotNull(result.FullError);
            Assert.Equal(result.FullOutput, @"acb876");
            Assert.Equal(result.FullStd, @"acb876");
            Assert.Equal(result.FullError, @"");
        }
Ejemplo n.º 3
0
 public void Fail()
 {
     Assert.ThrowsExact <AssertionException>(Assert.Failure);
     Assert.ThrowsExact <AssertionException>(() => Assert.Fail());
 }