using System.Collections.Generic; using Util.Helpers; using Xunit; namespace Util.Tests.Helpers { /// /// 命令行操作测试 /// public class CommandLineTest { /// /// 测试设置命令参数 - 1个参数 /// [Fact] public void TestArguments_1() { var command = new CommandLine().Command( "dapr" ).Arguments( "run" ); Assert.Equal( "dapr run", command.GetDebugText()); } /// /// 测试设置命令参数 - 多个参数 /// [Fact] public void TestArguments_2() { var command = new CommandLine().Command( "dapr" ).Arguments( "run", "--app-id","80" ); Assert.Equal( "dapr run --app-id 80", command.GetDebugText() ); } /// /// 测试设置命令参数 - 数组参数 /// [Fact] public void TestArguments_3() { var list = new List { "run", "--app-id", "80" }; var command = new CommandLine().Command( "dapr" ).Arguments( list ); Assert.Equal( "dapr run --app-id 80", command.GetDebugText() ); } /// /// 测试设置命令参数 - 多次调用Arguments /// [Fact] public void TestArguments_4() { var list = new List { "--app-id", "80" }; var command = new CommandLine().Command( "dapr" ).Arguments( "run" ).Arguments( list ); Assert.Equal( "dapr run --app-id 80", command.GetDebugText() ); } /// /// 测试根据条件设置命令参数 /// [Fact] public void TestArgumentsIf() { var command = new CommandLine().Command( "dapr" ).ArgumentsIf( false,"run" ); Assert.Equal( "dapr ", command.GetDebugText() ); } } }