public void Should_Return_Exception_Whern_Input_IntArgs_Error(string argsText) { string schemaText = "l:bool p:int d:string"; ArgsParser argsArray = InitArgsParam(argsText, schemaText, out ArgsSchema argsSchema); //3.根据argsValues, argsSchema获取value var args = new Args.Args(argsArray, argsSchema); Assert.Throws <ArgumentException>(() => args.GetValue("p"), "-p:不是有效的int类型!"); }
public void Should_Return_Value_Whern_Input_WithOut_l(object expectedVal, string key) { string argsText = "-p"; string schemaText = "l:bool p:int d:string"; ArgsParser argsArray = InitArgsParam(argsText, schemaText, out ArgsSchema argsSchema); //3.根据argsValues, argsSchema获取value var args = new Args.Args(argsArray, argsSchema); Assert.AreEqual(expectedVal, args.GetValue(key)); }
public void Should_Return_IEnumerable_Whern_Input_d() { string argsText = "-g this,is,a,list -d 1,2,-3,5"; string schemaText = "g:List<string> d:List<int>"; ArgsParser argsArray = InitArgsParam(argsText, schemaText, out ArgsSchema argsSchema); var args = new Args.Args(argsArray, argsSchema); var expectValue = new List <int>() { 1, 2, -3, 5 }; Assert.AreEqual(expectValue, args.GetValue("d")); }