Exemplo n.º 1
0
        public void BaseGetDoubleValue()
        {
            string          expectedA = "TheValue";
            string          expectedB = null;
            TestCommandLine blp       = new TestCommandLine();

            blp.AddSwitch("AValue", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch));
            blp.AddSwitch("BValue", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch));
            string[] cmdLine = { "-avalue", expectedA };
            blp.ProcessCommandLine(cmdLine);
            string actual = blp.GetSwitchValue("AVALUE");

            Assert.AreEqual(expectedA, actual);
            actual = blp.GetSwitchValue("BValue");
            Assert.AreEqual(expectedB, actual);
        }
Exemplo n.º 2
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]);
        }
Exemplo n.º 3
0
        public void BaseGetTripleValueWithDefault()
        {
            string          server    = "TheValue";
            string          database  = "Decon 1";
            string          directory = "Defcon 2";
            TestCommandLine blp       = new TestCommandLine();

            blp.AddSwitch("Server", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch));
            blp.AddSwitch("Database", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch, database));
            blp.AddSwitch("Directory", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch, directory));
            string[] cmdLine = { "-server", server };
            blp.ProcessCommandLine(cmdLine);
            string actual = blp.GetSwitchValue("server");

            Assert.AreEqual(server, actual);
            actual = blp.GetSwitchValue("database");
            Assert.AreEqual(database, actual);
            actual = blp.GetSwitchValue("directory");
            Assert.AreEqual(directory, actual);
        }
Exemplo n.º 4
0
        public void GetValueOfSwitchNotSpecified()
        {
            TestCommandLine blp = new TestCommandLine();

            blp.AddSwitch("OKGO", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch));
            blp.AddSwitch("MoreToTest", new SwitchDescription(SwitchDescription.SwitchTypeOption.ValueSwitch));
            blp.AddSwitch("v", new SwitchDescription(SwitchDescription.SwitchTypeOption.TrueFalse));
            string[] cmdLine = { "-okgo", "test", "/v" };
            blp.ProcessCommandLine(cmdLine);
            string actual = blp.GetSwitchValue("MoreToTest");

            Assert.AreEqual(null, actual);
        }