public void ParseFloats() { ValueArgument <float> argument = new ValueArgument <float>("float", "Description") { Category = "Category", IsOptional = true, AllowMultiple = true, }; Assert.AreEqual("float", argument.Name); Assert.AreEqual("Description", argument.Description); Assert.AreEqual("Category", argument.Category); Assert.IsFalse(string.IsNullOrEmpty(argument.GetSyntax())); Assert.IsFalse(string.IsNullOrEmpty(argument.GetHelp())); Assert.IsTrue(argument.AllowMultiple); int i = 1; string[] args = { "other", "123.4", "-567.8", }; var result = (ArgumentResult <float>)argument.Parse(args, ref i); Assert.AreEqual(3, i); Assert.AreEqual(2, result.Values.Count); Assert.AreEqual(123.4f, result.Values[0]); Assert.AreEqual(-567.8f, result.Values[1]); }
public void ParseCustomType() { ValueArgument<CustomType> argument = new ValueArgument<CustomType>("Custom", "") { AllowMultiple = true }; int i = 1; string[] args = { "other", "Xyz", "12345" }; var result = (ArgumentResult<CustomType>)argument.Parse(args, ref i); Assert.AreEqual(3, i); Assert.AreEqual(2, result.Values.Count); Assert.AreEqual("Xyz", result.Values[0].Value); Assert.AreEqual("12345", result.Values[1].Value); }
public void ParseCustomType() { ValueArgument <CustomType> argument = new ValueArgument <CustomType>("Custom", "") { AllowMultiple = true }; int i = 1; string[] args = { "other", "Xyz", "12345" }; var result = (ArgumentResult <CustomType>)argument.Parse(args, ref i); Assert.AreEqual(3, i); Assert.AreEqual(2, result.Values.Count); Assert.AreEqual("Xyz", result.Values[0].Value); Assert.AreEqual("12345", result.Values[1].Value); }
public void ParseFloat() { ValueArgument<float> argument = new ValueArgument<float>("float", "Description") { Category = "Category", IsOptional = true, }; Assert.AreEqual("float", argument.Name); Assert.AreEqual("Description", argument.Description); Assert.AreEqual("Category", argument.Category); Assert.IsFalse(string.IsNullOrEmpty(argument.GetSyntax())); Assert.IsFalse(string.IsNullOrEmpty(argument.GetHelp())); Assert.IsFalse(argument.AllowMultiple); int i = 1; string[] args = { "other", "123.4", "-456", "other" }; var result = (ArgumentResult<float>)argument.Parse(args, ref i); Assert.AreEqual(2, i); Assert.AreEqual(1, result.Values.Count); Assert.AreEqual(123.4f, result.Values[0]); }