From e70e89fc7124ac2581ab2091f36dcf0c84002ed4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 7 Jul 2014 21:11:46 +0200 Subject: [PATCH] Add unit test for options. --- .../net/pterodactylus/sone/core/OptionsTest.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/core/OptionsTest.java 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} + +} -- 2.7.4