Exemplo n.º 1
0
        public void Pickers_ShouldAllHaveValidExamples_MatchingRegex(Type pickerType)
        {
            var oc = new ObjectConstructor();

            var mem = new MemoryDataExportRepository();

            mem.MEF = MEF;

            //create some objects that the examples can successfully reference
            new Catalogue(mem.CatalogueRepository, "mycata1"); //ID = 1
            new Catalogue(mem.CatalogueRepository, "mycata2"); //ID = 2
            new Catalogue(mem.CatalogueRepository, "mycata3"); //ID = 3

            PickObjectBase picker = (PickObjectBase)oc.Construct(pickerType, GetActivator(new RepositoryProvider(mem)));

            Assert.IsNotEmpty(picker.Help, "No Help for picker {0}", picker);
            Assert.IsNotEmpty(picker.Format, "No Format for picker {0}", picker);
            Assert.IsNotNull(picker.Examples, "No Examples for picker {0}", picker);
            Assert.IsNotEmpty(picker.Examples, "No Examples for picker {0}", picker);

            foreach (var example in picker.Examples)
            {
                //examples should be matched by the picker!
                Assert.IsTrue(picker.IsMatch(example, 0), "Example of picker '{0}' did not match the regex,listed example is '{1}'", picker, example);

                var result = picker.Parse(example, 0);

                Assert.IsNotNull(result);
            }
        }
Exemplo n.º 2
0
        private CommandLineObjectPickerArgumentValue ReadLineWithAuto(PickObjectBase picker)
        {
            if (DisallowInput)
            {
                throw new InputDisallowedException("Value required");
            }

            string line = ReadLineWithAuto(picker.GetAutoCompleteIfAny());

            return(picker.Parse(line, 0));
        }
Exemplo n.º 3
0
        private CommandLineObjectPickerArgumentValue ReadLine(PickObjectBase picker)
        {
            if (DisallowInput)
            {
                throw new InputDisallowedException("Value required");
            }

            Console.WriteLine($"Format: {picker.Format}");
            string line = ReadLine(picker.GetAutoCompleteIfAny());

            return(picker.Parse(line, 0));
        }