Added junit dependency, added input contract
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
9c64c708eb
commit
143eb7036a
@ -51,6 +51,11 @@
|
||||
<artifactId>gclc</artifactId>
|
||||
<version>2.0.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<reporting>
|
||||
<plugins>
|
||||
|
@ -0,0 +1,37 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package net.bigeon.gclc.test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.bigeon.gclc.manager.ConsoleInput;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bigeon
|
||||
*
|
||||
*/
|
||||
public final class InputContract {
|
||||
|
||||
public void testInputContract(final Supplier<ConsoleInput> inputs)
|
||||
throws IOException {
|
||||
// Test close contract
|
||||
final ConsoleInput input = inputs.get();
|
||||
assertFalse("An input should not initially be closed", input.isClosed());
|
||||
input.close();
|
||||
assertTrue("An input should close", input.isClosed());
|
||||
input.close();
|
||||
assertTrue("A closed input should stay closed", input.isClosed());
|
||||
try {
|
||||
input.prompt();
|
||||
fail("Closed input prompting should fail");
|
||||
} catch (final IOException e) {
|
||||
// ok
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user