Example #1
0
        public void OptionCollection_AddLookupOpt_AddsOptionHandlerWithOptComparer()  // OPT
        {
            Option option1 = new Option("name_1");
            Option option2 = new Option("name_2_");

            OptionCollection optionCollection = new OptionCollection();

            optionCollection.Add(option1);
            optionCollection.Add(option2);

            optionCollection.AddLookupOpt("name_1");
            optionCollection.AddLookupOpt("name_2_");

            Option result11 = optionCollection.LookupOption("name_1");
            Option result12 = optionCollection.LookupOption("name-1");

            Assert.Equal(option1, result11);
            Assert.Equal(option1, result12);

            Option result21 = optionCollection.LookupOption("name_2");
            Option result22 = optionCollection.LookupOption("name-2");

            Assert.Equal(option2, result21);
            Assert.Equal(option2, result22);
        }
Example #2
0
        public void OptionCollection_LookupOption_ReplacesMinusToUnderscoreBeforeSearching()
        {
            Option option1 = new Option("name_1");

            option1.On("whence");
            OptionCollection optionCollection = new OptionCollection();

            optionCollection.Add(option1);
            optionCollection.AddLookupOpt("name_1");
            Option result = optionCollection.LookupOption("name-1"); // search with minus

            Assert.Equal(option1, result);
        }
Example #3
0
        public void OptionCollection_LookupOption_ReturnsNullIfOptionisNotFound()
        {
            object parent  = new object();
            Option option1 = new Option("name_1");

            option1.On("whence");
            OptionCollection optionCollection = new OptionCollection();

            optionCollection.Add(option1);
            optionCollection.AddLookupOpt("name_1");
            Option result = optionCollection.LookupOption("dummy");  // unknown name

            Assert.Null(result);
        }
Example #4
0
        public void OptionCollection_LookupOption_SetsParentForFoundItem()
        {
            object parent  = new object();
            Option option1 = new Option("name_1");

            option1.On("whence");
            OptionCollection optionCollection = new OptionCollection();

            optionCollection.Add(option1);
            optionCollection.AddLookupOpt("name_1");
            Option result = optionCollection.LookupOption("name_1", parent);  // send parent

            Assert.Equal(option1, result);
            Assert.Equal(option1.Parent, parent);
        }