Run() public static method

public static Run ( string command, string arguments ) : void
command string
arguments string
return void
Esempio n. 1
0
        public void TestPiping()
        {
            var shell = new Shell(o => o.ThrowOnError());

            var kinds = Enum.GetValues(typeof(Kind)).Cast<Kind>();
            foreach (var inKind in kinds)
            {
                foreach (var outKind in kinds.Where(k => k != Kind.String))
                {
                    dynamic input = this.CreateSinkOrSource(inKind, isOut: false);
                    dynamic output = this.CreateSinkOrSource(outKind, isOut: true);
                    var command = shell.Run("SampleCommand", "echo");
                    var tasks = new List<Task>();
                    if (input is TextReader)
                    {
                        tasks.Add(command.StandardInput.PipeFromAsync((TextReader)input));
                    }
                    else
                    {
                        command = command < input;
                    }
                    if (output is TextWriter)
                    {
                        tasks.Add(command.StandardOutput.PipeToAsync((TextWriter)output));
                    }
                    else
                    {
                        command = command > output;
                    }
                    tasks.Add(command.Task);
                    Task.WaitAll(tasks.ToArray());

                    string result = this.Read(outKind, output);
                    // MA: the output changes slightly if we are inputting as lines (adds a newline) and not outputting as lines
                    result.ShouldEqual(Content + (inKind == Kind.Lines && outKind != Kind.Lines ? Environment.NewLine : string.Empty), inKind + " => " + outKind);
                }
            }
        }