|
| 1 | +using FluentAssertions; |
| 2 | +using Xunit; |
| 3 | +using Xunit.Abstractions; |
| 4 | + |
| 5 | +namespace ProcNet.Tests; |
| 6 | + |
| 7 | +public class PrintArgsTests(ITestOutputHelper output) : TestsBase |
| 8 | +{ |
| 9 | + [Fact] |
| 10 | + public void ProcSendsAllArguments() |
| 11 | + { |
| 12 | + string[] testArgs = ["hello", "world"]; |
| 13 | + AssertOutput(testArgs); |
| 14 | + } |
| 15 | + |
| 16 | + [Fact] |
| 17 | + public void ArgumentsWithSpaceAreNotSplit() |
| 18 | + { |
| 19 | + string[] testArgs = ["hello", "world", "this argument has spaces"]; |
| 20 | + AssertOutput(testArgs); |
| 21 | + } |
| 22 | + |
| 23 | + [Fact] |
| 24 | + public void ArgumentsSeesArgumentsAfterQuoted() |
| 25 | + { |
| 26 | + string[] testArgs = ["this argument has spaces", "hello", "world"]; |
| 27 | + AssertOutput(testArgs); |
| 28 | + } |
| 29 | + [Fact] |
| 30 | + public void EscapedQuotes() |
| 31 | + { |
| 32 | + string[] testArgs = ["\"this argument has spaces\"", "hello", "world"]; |
| 33 | + AssertOutput(testArgs); |
| 34 | + } |
| 35 | + |
| 36 | + private void AssertOutput(string[] testArgs) |
| 37 | + { |
| 38 | + var args = TestCaseArguments("PrintArgs", testArgs); |
| 39 | + var outputWriter = new TestConsoleOutWriter(output); |
| 40 | + var result = Proc.Start(args, WaitTimeout, outputWriter); |
| 41 | + result.ExitCode.Should().Be(0); |
| 42 | + result.ConsoleOut.Should().NotBeEmpty().And.HaveCount(testArgs.Length); |
| 43 | + for (var i = 0; i < result.ConsoleOut.Count; i++) |
| 44 | + result.ConsoleOut[i].Line.Should().Be(testArgs[i], i.ToString()); |
| 45 | + } |
| 46 | + |
| 47 | +} |
0 commit comments