Example #1
0
        public void TestThatUsesSwitchIsParsed()
        {
            var options = new BasicOptionParser();

            options.Parse("--required-option");
            Assert.IsFalse(options.Usage.IsDefined);

            options.Parse("--required-option", "--help");
            Assert.IsTrue(options.Usage.IsDefined);
        }
Example #2
0
        public void TestThatUsesSwitchBypassesOptionValidation()
        {
            var options = new BasicOptionParser();

            options.Parse("--help");
            Assert.IsTrue(options.Usage.IsDefined);
        }
Example #3
0
        public void TestThatShortNameParsesCorrectly()
        {
            var options = new BasicOptionParser();

            options.Parse("-r");

            Assert.IsTrue(options.MyRequiredOption.IsDefined);
        }
Example #4
0
        public void TestThatSwitchOverridesDefaultValue()
        {
            var options = new BasicOptionParser();

            options.Parse("--required-option", "-i", "5");
            Assert.IsTrue(options.MyIntOption.IsDefined);
            Assert.IsTrue(options.MyIntOption.Value == 5);
        }
Example #5
0
        public void TestThatDefaultValueIsUsed()
        {
            var options = new BasicOptionParser();

            Assert.IsTrue(options.MyIntOption.DefaultValue == "3");
            Assert.IsTrue(options.MyIntOption.Value == 3);

            options.Parse("--required-option");
            Assert.IsFalse(options.MyIntOption.IsDefined);
            Assert.IsTrue(options.MyIntOption.Value == 3);
        }
Example #6
0
        public void TestForRequiredOptions()
        {
            var options = new BasicOptionParser();

            Assert.ThrowsException <SyntaxErrorException>(() => options.Parse());
        }
Example #7
0
        public void TestThatWrongArgumentStringThrowsException()
        {
            var options = new BasicOptionParser();

            options.Parse("-i", bool.TrueString);
        }