Пример #1
0
        //[Fact]
        //public void RetrieveNotExistentShortOption()
        //{
        //    var shortOi = _optionMap["y"];
        //    shortOi.Should().BeNull();
        //}

        //[Fact]
        //public void RetrieveNotExistentLongOption()
        //{
        //    var longOi = _optionMap["nomorebugshere"];
        //    longOi.Should().BeNull();
        //}

        private static OptionMap CreateMap(ref OptionMap map, IDictionary <string, OptionInfo> optionCache)
        {
            if (map == null)
            {
                map = new OptionMap(3, new ParserSettings(true));
            }

            var attribute1 = new OptionAttribute('p', "pretend");
            var attribute2 = new OptionAttribute("newuse");
            var attribute3 = new OptionAttribute('D', null);

            var option1 = attribute1.CreateOptionInfo();
            var option2 = attribute2.CreateOptionInfo();
            var option3 = attribute3.CreateOptionInfo();

            map[attribute1.UniqueName] = option1;
            map[attribute2.UniqueName] = option2;
            map[attribute3.UniqueName] = option3;

            if (optionCache != null)
            {
                optionCache[attribute1.UniqueName] = option1;
                optionCache[attribute1.UniqueName] = option2;
                optionCache[attribute2.UniqueName] = option3;
            }

            return(map);
        }
Пример #2
0
            public void AppendOption(char shortName, string longName)
            {
                var oa = new OptionAttribute(shortName, longName);
                var oi = oa.CreateOptionInfo();

                _optionMap[oa.UniqueName] = oi;
                _options.Add(oi);
                _names.Add(oa.UniqueName);
            }
Пример #3
0
        public void ManageOptions()
        {
            OptionAttribute attribute1 = new OptionAttribute("p", "pretend");
            OptionAttribute attribute2 = new OptionAttribute(null, "newuse");
            OptionAttribute attribute3 = new OptionAttribute("D", null);

            OptionInfo option1 = attribute1.CreateOptionInfo();
            OptionInfo option2 = attribute2.CreateOptionInfo();
            OptionInfo option3 = attribute3.CreateOptionInfo();

            optionMap[attribute1.UniqueName] = option1;
            optionMap[attribute2.UniqueName] = option2;
            optionMap[attribute3.UniqueName] = option3;

            Assert.AreSame(option1, optionMap[attribute1.UniqueName]);
            Assert.AreSame(option2, optionMap[attribute2.UniqueName]);
            Assert.AreSame(option3, optionMap[attribute3.UniqueName]);
        }