Beispiel #1
0
        public void ParseWithDifferentAssignmentOperators()
        {
            var parser = new BasicCommandLineTest();

            parser.Parse(new string[] { "--testParam='123'" });
            Assert.AreEqual("123", parser.TestParam);

            parser.Parse(new string[] { "--testParam=\"123\"" });
            Assert.AreEqual("123", parser.TestParam);

            parser.Parse(new string[] { "-testParam '123'" });
            Assert.AreEqual("123", parser.TestParam);

            parser.Parse(new string[] { " -testParam '123'" });
            Assert.AreEqual("123", parser.TestParam);

            parser.Parse(new string[] { " -testInt: 123" });
            Assert.AreEqual(123, parser.Int32Param);

            parser.Parse(new string[] { "-testInt:123" });
            Assert.AreEqual(123, parser.Int32Param);

            parser.Parse(new string[] { "-testInt 123" });
            Assert.AreEqual(123, parser.Int32Param);

            parser.Parse(new string[] { "-testInt=123 " });
            Assert.AreEqual(123, parser.Int32Param);
        }
Beispiel #2
0
        public void ParseOneParameterWithValue()
        {
            var parser = new BasicCommandLineTest();

            parser.Parse(new string[] { "--testParam=123" });
            Assert.AreEqual("123", parser.TestParam);
        }
Beispiel #3
0
 public void ShouldThrowInvalidProgramExceptionOnInvalidValueForParam()
 {
     var parser = new BasicCommandLineTest();
     Assert.Throws(typeof(InvalidProgramException), delegate
     {
         parser.Parse(new string[] { "--testBool 123" }); // Wrong value for type bool
     });
 }
Beispiel #4
0
        public void ShouldBeAbleToAcceptDifferentTypes()
        {
            var parser = new BasicCommandLineTest();

            parser.Parse(new string[] { "--testInt 100" });

            Assert.IsFalse(parser.BooleanParam);
            Assert.AreEqual(100, parser.Int32Param);
        }
Beispiel #5
0
        public void ShouldBeAbleToParseMultipleTimes()
        {
            var parser = new BasicCommandLineTest();

            Assert.IsFalse(parser.BooleanParam);

            parser.Parse(new string[] { "--testBool" });
            Assert.IsTrue(parser.BooleanParam);

            parser.Parse(new string[] { "--testBool false" });
            Assert.IsFalse(parser.BooleanParam);
        }
 public void SetupEachTest()
 {
     parser = new BasicCommandLineTest();
 }
Beispiel #7
0
        public void TestOneParameterWithoutValue()
        {
            var parser = new BasicCommandLineTest();

            parser.Parse(new string[] { "--testBool" });
            Assert.IsTrue(parser.BooleanParam);
        }
Beispiel #8
0
        public void TestTokenize()
        {
            var parser = new BasicCommandLineTest();

            var result = parser.Tokenize("--heppas -was a 'ninja'");
            Assert.AreEqual(9, result.Count);
            Assert.AreEqual(5, result.Where(r => r.Item2 == Parser.Token.Separator).Count());
            Assert.AreEqual(3, result.Where(r => r.Item2 == Parser.Token.Identifier).Count());
            Assert.AreEqual(1, result.Where(r => r.Item2 == Parser.Token.String).Count());
        }
Beispiel #9
0
 public void SetupEachTest()
 {
     parser = new BasicCommandLineTest();
 }