Exemplo n.º 1
0
        public void TestData()
        {
            bool lExecuted = false;
            bool zExecuted = false;

            var clm = new CommandLineManager();

            clm.AddOptionRequiresData("L", "List out the operation.", (clmanager) => lExecuted = true);
            clm.AddOption("S,Save", "Save the operation.");
            clm.AddOption("Zebra", "Zero out the operation.", (clmanager) => zExecuted = true);

            clm.Execute(new[] { "-L", "Data", "-Zebra", "-Save", "Unknown" });


            Assert.IsTrue(clm.L);
            Assert.IsTrue(clm["L"].Equals("Data"));

            Assert.IsTrue(string.IsNullOrEmpty(clm["Z"]));
            Assert.IsTrue(clm.S);
            Assert.IsTrue(string.IsNullOrEmpty(clm["S"]));
            Assert.IsFalse(clm.D);
            Assert.IsTrue(string.IsNullOrEmpty(clm["D"]));
            Assert.IsTrue(lExecuted);
            Assert.IsFalse(clm.Z);
            Assert.IsTrue(zExecuted);
        }
Exemplo n.º 2
0
        public void TestBasic()
        {
            bool lExecuted = false;
            bool zExecuted = false;

            var clm = new CommandLineManager();

            clm.AddOption("L", "List out the operation.", (clmanager) => lExecuted = true);
            clm.AddOption("S,Save", "Save the operation.");
            clm.AddOption("Zebra", "Zero out the operation.", (clmanager) => zExecuted = true);

            clm.Execute(new[] { "-L", "Data", "-Zebra", "-Save" });


            Assert.IsTrue(clm.L);
            Assert.IsTrue(clm.IsMultipleLetterOptionFound("L"));
            Assert.IsFalse(clm.IsMultipleLetterOptionFound("Data"));
            Assert.IsTrue(clm.S);
            Assert.IsFalse(clm.D);
            Assert.IsTrue(lExecuted);

            Assert.IsTrue(clm.IsMultipleLetterOptionFound("Zebra"));

            Assert.IsFalse(clm.Z);
            Assert.IsTrue(zExecuted);
        }