From: David ‘Bombe’ Roden Date: Mon, 7 Jul 2014 19:11:46 +0000 (+0200) Subject: Add unit test for options. X-Git-Tag: 0.9-rc1^2~3^2~213 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=e70e89fc7124ac2581ab2091f36dcf0c84002ed4;hp=ad5d4046c53129d23b3acf4eb6aa8643dbef2f86 Add unit test for options. --- diff --git a/src/test/java/net/pterodactylus/sone/core/OptionsTest.java b/src/test/java/net/pterodactylus/sone/core/OptionsTest.java new file mode 100644 index 0000000..46b2ad5 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/core/OptionsTest.java @@ -0,0 +1,55 @@ +package net.pterodactylus.sone.core; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.mockito.Mockito.mock; + +import net.pterodactylus.sone.core.Options.Option; + +import org.junit.Test; + +/** + * Unit test for {@link Options}. + * + * @author David ‘Bombe’ Roden + */ +public class OptionsTest { + + private final Options options = new Options(); + + @Test + public void booleanOptionIsAdded() { + Option booleanOption = mock(Option.class); + options.addBooleanOption("test", booleanOption); + assertThat(options.getBooleanOption("test"), is(booleanOption)); + assertThat(options.getBooleanOption("not-test"), nullValue()); + } + + @Test + public void integerOptionIsAdded() { + Option integerOption = mock(Option.class); + options.addIntegerOption("test", integerOption); + assertThat(options.getIntegerOption("test"), is(integerOption)); + assertThat(options.getIntegerOption("not-test"), nullValue()); + } + + @Test + public void stringOptionIsAdded() { + Option stringOption = mock(Option.class); + options.addStringOption("test", stringOption); + assertThat(options.getStringOption("test"), is(stringOption)); + assertThat(options.getStringOption("not-test"), nullValue()); + } + + @Test + public void enumOptionIsAdded() { + Option enumOption = mock(Option.class); + options.addEnumOption("test", enumOption); + assertThat(options.getEnumOption("test"), is(enumOption)); + assertThat(options.getEnumOption("not-test"), nullValue()); + } + + private enum TestEnum {TEST, NOT_TEST} + +}