Пример #1
0
        public void Values_from_options_on_parent_commands_can_be_bound_regardless_of_naming()
        {
            var childCommand = new Command("child-command");
            var option       = new Option("-x")
            {
                Argument = new Argument <int>()
            };
            var parentCommand = new Command("parent-command")
            {
                option,
                childCommand
            };

            var binder = new ModelBinder <ClassWithMultiLetterSetters>();

            binder.BindMemberFromOption(
                c => c.IntOption,
                option);

            var bindingContext = new BindingContext(parentCommand.Parse("parent-command -x 123 child-command"));

            var instance = (ClassWithMultiLetterSetters)binder.CreateInstance(bindingContext);

            instance.IntOption.Should().Be(123);
        }