ParseArguments() static private method

“/key:value”形式の起動オプションを解釈し IDictionary に変換する
不正な形式のオプションは除外されます。 また、重複したキーのオプションが入力された場合は末尾に書かれたオプションが採用されます。
static private ParseArguments ( IEnumerable arguments ) : string>.IDictionary
arguments IEnumerable
return string>.IDictionary
Beispiel #1
0
        public void ParseArguments_OptionWithEmptyArgumentTest()
        {
            var args = new[] { "/foo:" };

            Assert.Equal(new Dictionary <string, string>
            {
                ["foo"] = "",
            },
                         MyApplication.ParseArguments(args));
        }
Beispiel #2
0
        public void ParseArguments_DuplicateOptionsTest()
        {
            var args = new[] { "/foo:abc", "/foo:123" };

            Assert.Equal(new Dictionary <string, string>
            {
                ["foo"] = "123",
            },
                         MyApplication.ParseArguments(args));
        }
Beispiel #3
0
        public void OptionWithArgumentTest()
        {
            var args = new[] { "/foo:hogehoge" };

            Assert.Equal(new Dictionary <string, string>
            {
                { "foo", "hogehoge" },
            },
                         MyApplication.ParseArguments(args));
        }
Beispiel #4
0
        public void SingleOptionTest()
        {
            var args = new[] { "/foo" };

            Assert.Equal(new Dictionary <string, string>
            {
                { "foo", "" },
            },
                         MyApplication.ParseArguments(args));
        }
Beispiel #5
0
        public void ParseArguments_MultipleOptionsTest()
        {
            var args = new[] { "/foo", "/bar" };

            Assert.Equal(new Dictionary <string, string>
            {
                ["foo"] = "",
                ["bar"] = "",
            },
                         MyApplication.ParseArguments(args));
        }
Beispiel #6
0
        public void ParseArguments_IgroreInvalidOptionsTest()
        {
            var args = new string[] { "--foo", "/" };

            Assert.Empty(MyApplication.ParseArguments(args));
        }
Beispiel #7
0
        public void ParseArguments_NoOptionsTest()
        {
            var args = new string[] { };

            Assert.Empty(MyApplication.ParseArguments(args));
        }