public virtual void TestSimpleDoublePresent() { var args = new com.cleancoder.args.Args("x##", new string[] { "-x", "42.3" }); Assert.True(args.has('x')); Assert.Equal(42.3, args.getDouble('x'), 3); }
public virtual void TestSimpleBooleanPresent() { var args = new com.cleancoder.args.Args("x", new string[] { "-x" }); Assert.True(args.getBoolean('x')); Assert.Equal(1, args.nextArgument()); }
public virtual void TestExtraArguments() { var args = new com.cleancoder.args.Args("x,y*", new string[] { "-x", "-y", "alpha", "beta" }); Assert.True(args.getBoolean('x')); Assert.Equal("alpha", args.getString('y')); Assert.Equal(3, args.nextArgument()); }
public virtual void TestSimpleIntPresent() { var args = new com.cleancoder.args.Args("x#", new string[] { "-x", "42" }); Assert.True(args.has('x')); Assert.Equal(42, args.getInt('x')); Assert.Equal(2, args.nextArgument()); }
public virtual void TestSpacesInFormat() { var args = new com.cleancoder.args.Args("x, y", new string[] { "-xy" }); Assert.True(args.has('x')); Assert.True(args.has('y')); Assert.Equal(1, args.nextArgument()); }
public virtual void TestSimpleStringPresent() { var args = new com.cleancoder.args.Args("x*", new string[] { "-x", "param" }); Assert.True(args.has('x')); Assert.Equal("param", args.getString('x')); Assert.Equal(2, args.nextArgument()); }
public virtual void OneMapArgument() { var args = new com.cleancoder.args.Args("f&", new string[] { "-f", "key1:val1" }); Assert.True(args.has('f')); IDictionary <string, string> map = args.getMap('f'); Assert.Equal("val1", map["key1"]); }
public virtual void TestStringArray() { var args = new com.cleancoder.args.Args("x[*]", new string[] { "-x", "alpha" }); Assert.True(args.has('x')); string[] result = args.getStringArray('x'); Assert.Single(result); Assert.Equal("alpha", result[0]); }
public virtual void TestExtraArgumentsThatLookLikeFlags() { var args = new com.cleancoder.args.Args("x,y", new string[] { "-x", "alpha", "-y", "beta" }); Assert.True(args.has('x')); Assert.False(args.has('y')); Assert.True(args.getBoolean('x')); Assert.False(args.getBoolean('y')); Assert.Equal(1, args.nextArgument()); }
public virtual void ManyStringArrayElements() { var args = new com.cleancoder.args.Args("x[*]", new string[] { "-x", "alpha", "-x", "beta", "-x", "gamma" }); Assert.True(args.has('x')); string[] result = args.getStringArray('x'); Assert.Equal(3, result.Length); Assert.Equal("alpha", result[0]); Assert.Equal("beta", result[1]); Assert.Equal("gamma", result[2]); }
public virtual void MalFormedMapArgument() { try { var args = new com.cleancoder.args.Args("f&", new string[] { "-f", "key1:val1,key2" }); } catch (ArgsException e) { Assert.Equal(ErrorCode.MALFORMED_MAP, e.getErrorCode()); Assert.Equal('f', e.ErrorArgumentId); } }
public virtual void TestInvalidDouble() { try { var args = new com.cleancoder.args.Args("x##", new string[] { "-x", "Forty two" }); //fail(); } catch (ArgsException e) { Assert.Equal(ErrorCode.INVALID_DOUBLE, e.getErrorCode()); Assert.Equal('x', e.ErrorArgumentId); Assert.Equal("Forty two", e.ErrorParameter); } }
public virtual void TestCreateWithNoSchemaOrArguments() { var args = new com.cleancoder.args.Args("", new string[0]); Assert.Equal(0, args.nextArgument()); }