コード例 #1
0
  @Test
  public void it_should_produce_a_scheme_that_knows_only_the_added_options() {
    schemeBuilder.addOption(firstOpt);
    CommandScheme scheme = schemeBuilder.buildScheme();

    assertThat(scheme.hasOption("unknown option"), is(false));
  }
コード例 #2
0
  @Test
  public void it_should_build_a_scheme() {
    schemeBuilder.addOption(firstOpt);
    CommandScheme scheme = schemeBuilder.buildScheme();

    assertThat(scheme.hasOption("basic option"), is(true));
  }
コード例 #3
0
  @Test
  public void it_should_produce_a_scheme_without_not_provided_commands() {
    schemeBuilder.addCommand(firstCmd);
    schemeBuilder.addCommand(firstCmd);

    CommandScheme scheme = schemeBuilder.buildScheme();
    assertThat(scheme.hasCommand("third"), is(false));
  }
コード例 #4
0
  @Test
  public void it_should_produce_a_scheme_with_the_proper_commands() {
    schemeBuilder.addCommand(firstCmd);
    schemeBuilder.addCommand(secondCmd);

    CommandScheme scheme = schemeBuilder.buildScheme();
    assertThat(scheme.hasCommand(firstCmd), is(true));
    assertThat(scheme.hasCommand(secondCmd), is(true));
  }
コード例 #5
0
  @Test
  public void it_should_reset_properly() {
    schemeBuilder.addOption(unkownOpt);
    schemeBuilder.reset();
    schemeBuilder.addOption(firstOpt);

    CommandScheme scheme = schemeBuilder.buildScheme();
    assertThat(scheme.hasOption("unknown option"), is(false));
    assertThat(scheme.hasOption("basic option"), is(true));
  }
コード例 #6
0
 @Test
 public void it_should_produce_an_empty_scheme() {
   assertThat(schemeBuilder.buildScheme(), not(nullValue()));
 }
コード例 #7
0
 @Test(expected = IllegalArgumentException.class)
 public void it_should_complain_when_adding_options_twice() {
   schemeBuilder.addOption(firstOpt);
   schemeBuilder.addOption(firstOpt);
   fail("Only one option with a specific long representation is allowed");
 }
コード例 #8
0
 @Test(expected = RuntimeException.class)
 public void it_should_complain_when_both_arguments_and_commands_are_used() {
   schemeBuilder.addCommand(firstCmd);
   schemeBuilder.addArgument(firstArg);
   fail("should not allow use of both arguments and commands");
 }