コード例 #1
0
            public void CanGetExitCode()
            {
                var spec = new ProcessSpec
                {
                    ExecutablePath = "run.bat",
                    Arguments      = new[] { "exit 100" }
                };
                var io = new TestProcessIO();

                var process  = Container.Run(spec, io);
                var exitCode = process.WaitForExit();

                Assert.Equal(100, exitCode);
            }
コード例 #2
0
            public void CanGetProcessErrors()
            {
                var spec = new ProcessSpec
                {
                    ExecutablePath = "run.bat",
                    Arguments      = new[] { "echo This is STDERR >&2" }
                };
                var io = new TestProcessIO();

                var process = Container.Run(spec, io);

                process.WaitForExit();

                Assert.Contains("This is STDERR", io.Error.ToString());
            }
コード例 #3
0
            public void CanSetEnvironmentVariables()
            {
                var spec = new ProcessSpec
                {
                    ExecutablePath = "run.bat",
                    Arguments      = new[] { "set" },
                    Environment    = new Dictionary <string, string>
                    {
                        { "FOO", "1" },
                        { "BAR", "two" }
                    }
                };
                var io = new TestProcessIO();

                var process = Container.Run(spec, io);

                process.WaitForExit();

                var stdout = io.Output.ToString();

                Assert.Contains("FOO=1", stdout);
                Assert.Contains("BAR=two", stdout);
            }