Пример #1
0
        public void AddedSwitches()
        {
            TestCommandLine blp = new TestCommandLine();

            blp.AddSwitch("?", new SwitchDescription(SwitchDescription.SwitchTypeOption.TrueFalse));
            blp.AddSwitch("A", new SwitchDescription(SwitchDescription.SwitchTypeOption.TrueFalse));
            string[] cmdLine = { "/a" };
            blp.ProcessCommandLine(cmdLine);
            Assert.IsTrue(blp.GetSwitchBool("a"));
            Assert.IsFalse(blp.GetSwitchBool("?"));
        }
Пример #2
0
        public void SimpleBaseInvalidTest()
        {
            TestCommandLine blp = new TestCommandLine();

            string[] cmdLine = { };
            blp.ProcessCommandLine(cmdLine);
            Assert.IsTrue(blp.GetSwitchBool("?"));
        }
Пример #3
0
        public void OddFailureNumberOne()
        {
            string          server    = "1FP0VF2";
            string          database  = "DbaAdmin";
            string          directory = @"c:\tmp\DbaAdmin";
            bool            overWrite = true;
            bool            ignore    = true;
            TestCommandLine blp       = new TestCommandLine();

            blp.AddSwitch("F", new SwitchDescription(SwitchDescription.SwitchTypeOption.TrueFalse));
            blp.AddSwitch("I", new SwitchDescription(SwitchDescription.SwitchTypeOption.TrueFalse));
            string[] cmdLine = { "1FP0VF2", "DbaAdmin", @"c:\tmp\DbaAdmin", "-i", "-f" };
            blp.ProcessCommandLine(cmdLine);
            Assert.AreEqual(3, blp.NonSwitchValues.Count);
            Assert.AreEqual(server, blp.NonSwitchValues[0]);
            Assert.AreEqual(database, blp.NonSwitchValues[1]);
            Assert.AreEqual(directory, blp.NonSwitchValues[2]);
            Assert.AreEqual(overWrite, blp.GetSwitchBool("f"));
            Assert.AreEqual(ignore, blp.GetSwitchBool("i"));
        }
Пример #4
0
        public void BaseValuesAndSwitchValuesAndTrueFalse()
        {
            string          ok       = "Nice Band";
            string          go       = "go";
            string          NoSwitch = "NoSwitch";
            bool            flag     = true;
            TestCommandLine blp      = new TestCommandLine();

            blp.AddSwitch("ok", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch));
            blp.AddSwitch("go", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch, go));
            blp.AddSwitch("flag", new SwitchDescription(SwitchDescription.SwitchTypeOption.TrueFalse));
            string[] cmdLine = { "-ok", "Nice Band", "NoSwitch", "-flag" };
            blp.ProcessCommandLine(cmdLine);
            Assert.AreEqual(ok, blp.GetSwitchValue("ok"));
            Assert.AreEqual(go, blp.GetSwitchValue("go"));
            Assert.AreEqual(flag, blp.GetSwitchBool("flag"));
            Assert.AreEqual(1, blp.NonSwitchValues.Count);
            Assert.AreEqual(NoSwitch, blp.NonSwitchValues[0]);
        }