public void CommandLine_as_using_valid_source_with_parameter_without_value_should_correctly_transalte_to_bool() { var target = new CommandLine( new[] { "username=Mauro", "password=P@ssw0rd", "admin=True" } ); var actual = target.As<UserDefinition>(); actual.Username.Should().Be.EqualTo("Mauro"); actual.Password.Should().Be.EqualTo( "P@ssw0rd" ); }
public void CommandLine_as_using_valid_source_with_alias_should_generate_the_expected_arguments() { var target = new CommandLine( new[] { "-s=foo" } ); var actual = target.As<SampleWithAliases>(); actual.Sample.Should().Be.EqualTo( "foo" ); }
public void CommandLine_as_using_valid_source_with_enum_should_generate_the_expected_arguments() { var target = new CommandLine( new[] { "-s=value" } ); var actual = target.As<SampleWithEnum>(); actual.Sample.Should().Be.EqualTo( SampleEnum.Value ); }
public void CommandLine_as_using_valid_command_line_with_spaces_in_one_value_should_convert_command_line_to_class_instance() { var target = new CommandLine( new[] { "-f=1", "-s=\"bar foo\"" } ); var instance = target.As<Sample>(); instance.FirstProperty.Should().Be.EqualTo( 1 ); instance.SecondProperty.Should().Be.EqualTo( "bar foo" ); }
public void CommandLine_as_using_valid_command_line_and_class_should_not_convert_command_line_to_class_instance_using_missing_required_arguments() { var target = new CommandLine( new String[ 0 ] ); var instance = target.As<Sample>(); }
public void CommandLine_as_using_valid_command_line_and_class_should_convert_command_line_to_class_instance_even_using_non_required_arguments() { var target = new CommandLine( new[] { "-f=1" } ); var instance = target.As<Sample>(); instance.FirstProperty.Should().Be.EqualTo( 1 ); instance.SecondProperty.Should().Be.Null(); }