コード例 #1
0
        public void CanAssignMultipleFlags()
        {
            var parameter = new NamedConsoleParameter <int>(new[] { "i", "int" }, () => Program.i, null);

            bool mapped1 = parameter.PerformMapping(new LinkedList <string>("-i 5".Split(' ')));

            Assert.AreEqual(5, Program.i);
            Assert.IsTrue(mapped1);

            bool mapped2 = parameter.PerformMapping(new LinkedList <string>("-int 5".Split(' ')));

            Assert.AreEqual(5, Program.i);
            Assert.IsTrue(mapped2);
        }
コード例 #2
0
        public void CanParseLastParameter()
        {
            var parameter = new NamedConsoleParameter <int>(new[] { "i" }, () => Program.i, null);

            bool mapped = parameter.PerformMapping(new LinkedList <string>("-aaa asdfsad -b -i 5".Split(' ')));

            Assert.AreEqual(5, Program.i);
            Assert.IsTrue(mapped);
        }
コード例 #3
0
        public void NotPresentDoesNotPerformMap()
        {
            var parameter = new NamedConsoleParameter <int>(new[] { "i" }, () => Program.i, null);

            bool mapped = parameter.PerformMapping(new LinkedList <string>("".Split(' ')));

            Assert.AreEqual(Program.i, default);
            Assert.IsFalse(mapped);
        }
コード例 #4
0
        public void ArgsRemovedOnSuccess()
        {
            var parameter = new NamedConsoleParameter <int>(new[] { "i" }, () => Program.i, null);

            var args = new LinkedList <string>("-q -i 5 -g".Split(' '));

            bool mapped = parameter.PerformMapping(args);;

            Assert.AreEqual(5, Program.i);
            Assert.IsTrue(mapped);
            Assert.AreEqual(2, args.Count);
            Assert.IsFalse(args.Contains("-i"));
            Assert.IsFalse(args.Contains("5"));
        }