コード例 #1
0
        public void Values_from_parent_command_arguments_can_be_bound_regardless_of_naming()
        {
            var childCommand = new Command("child-command");

            var parentCommand = new Command("parent-command", argument: new Argument <int>())
            {
                childCommand
            };

            var binder = new ModelBinder <ClassWithMultiLetterSetters>();

            binder.BindMemberFromCommand(
                c => c.IntOption,
                parentCommand);

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

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

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