public void Should_set_cardinality() { var args = new[] { "-l", "-d", "test" }; var arg = new Args("n#,d*,l", args); Assert.That(arg.Cardinality(), Is.EqualTo(2)); }
public void SimpleBooleanPresent() { var args = new Args("x", new string[] { "-x" }); Assert.Equal(1, args.Cardinality()); Assert.Equal(true, args.GetBoolean('x')); }
public void SimpleStringPresent() { var args = new Args("x*", new string[] { "-x", "param" }); Assert.Equal(1, args.Cardinality()); Assert.True(args.Has('x')); Assert.Equal("param", args.GetString('x')); }
public void SimpleDoublePresent() { var args = new Args("x##", new string[] { "-x", "42.3" }); Assert.Equal(1, args.Cardinality()); Assert.True(args.Has('x')); Assert.Equal(42.3, args.GetDouble('x')); }
public void SimpleIntPresent() { var args = new Args("x#", new string[] { "-x", "42" }); Assert.Equal(1, args.Cardinality()); Assert.True(args.Has('x')); Assert.Equal(42, args.GetInteger('x')); }
public void SpacesInFormat() { var args = new Args("x, y", new string[] { "-xy" }); Assert.Equal(2, args.Cardinality()); Assert.True(args.Has('x')); Assert.True(args.Has('y')); }
public void MissingStringArgument() { try { var args = new Args("x*", new string[] { "-x", "param" }); Assert.Equal(1, args.Cardinality()); Assert.True(args.Has('x')); Assert.Equal("param", args.GetString('x')); } catch (ArgsException e) { Assert.Equal(ErrorCode.MissingString, e.ErrorCode); Assert.Equal('x', e.ErrorArgumentId); } }
public void CreateWithNoSchemaOrArguments() { var args = new Args("", new string[0]); Assert.Equal(0, args.Cardinality()); }
public void SpacesInFormat() { var args = new Args("x, y", new[] { "-xy" }); Assert.True(args.Has('x')); Assert.True(args.Has('y')); Assert.AreEqual(2, args.Cardinality()); }
public void WhenArgumentNotPresentGetIntReturnsZero() { var args = new Args("x", new[] { "-x" }); Assert.AreEqual(0, args.GetInt('y')); Assert.AreEqual(1, args.Cardinality()); }
public void WhenArgumentNotPresentGetBooleanReturnsFalse() { var args = new Args("x#", new[] { "-x", "42" }); Assert.AreEqual(false, args.GetBoolean('y')); Assert.AreEqual(1, args.Cardinality()); }
public void CreateWithNoSchemaOrArguments() { var args = new Args("", new string[0]); Assert.AreEqual(0, args.Cardinality()); }
public void SimpleBooleanPresent() { var args = new Args("x", new[] { "-x" }); Assert.AreEqual(true, args.GetBoolean('x')); Assert.AreEqual(1, args.Cardinality()); }
public void ExtraArguments() { var args = new Args("x,y*", new[] { "-x", "-y", "alpha", "beta" }); Assert.True(args.GetBoolean('x')); Assert.AreEqual("alpha", args.GetString('y')); Assert.AreEqual(2, args.Cardinality()); }
public void SimpleDoublePresent() { var args = new Args("x##", new[] { "-x", "42.13" }); Assert.True(args.Has('x')); Assert.AreEqual(42.13, args.GetDouble('x')); Assert.AreEqual(1, args.Cardinality()); }
public void SimpleIntPresent() { var args = new Args("x#", new[] { "-x", "42" }); Assert.True(args.Has('x')); Assert.AreEqual(42, args.GetInt('x')); Assert.AreEqual(1, args.Cardinality()); }
public void WhenArgumentNotPresentGetStringReturnEmptyString() { var args = new Args("x", new[] { "-x" }); Assert.AreEqual("", args.GetString('y')); Assert.AreEqual(1, args.Cardinality()); }
public void SimpleStringPresent() { var args = new Args("x*", new[] { "-x", "param" }); Assert.True(args.Has('x')); Assert.AreEqual("param", args.GetString('x')); Assert.AreEqual(1, args.Cardinality()); }