@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)); }
@Test public void it_should_build_a_scheme() { schemeBuilder.addOption(firstOpt); CommandScheme scheme = schemeBuilder.buildScheme(); assertThat(scheme.hasOption("basic option"), is(true)); }
@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)); }
@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)); }
@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)); }
@Test public void it_should_produce_an_empty_scheme() { assertThat(schemeBuilder.buildScheme(), not(nullValue())); }
@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"); }
@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"); }