From bf6bbb16f6d76d0d72b10aa4055ed3a08ec182f0 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Wed, 12 Feb 2014 08:39:29 -0600 Subject: [PATCH] Add a couple tests which test the jewel system. --- .../com/graywolf336/jail/JewelCommands.java | 28 ----------- .../graywolf336/jail/TestJewelCommands.java | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+), 28 deletions(-) delete mode 100644 src/test/java/test/java/com/graywolf336/jail/JewelCommands.java create mode 100644 src/test/java/test/java/com/graywolf336/jail/TestJewelCommands.java diff --git a/src/test/java/test/java/com/graywolf336/jail/JewelCommands.java b/src/test/java/test/java/com/graywolf336/jail/JewelCommands.java deleted file mode 100644 index 99519ed..0000000 --- a/src/test/java/test/java/com/graywolf336/jail/JewelCommands.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.java.com.graywolf336.jail; - -import junit.framework.Assert; - -import org.junit.Test; - -import com.graywolf336.jail.command.commands.jewels.Jailing; -import com.lexicalscope.jewel.cli.CliFactory; - -public class JewelCommands { - @Test - public void testJewel() { - String[] args = { "--player", "graywolf336", "-c", "testing", "-r", "This", "is", "a", "reason" }; - Jailing j = CliFactory.parseArguments(Jailing.class, args); - - Assert.assertEquals("graywolf336", j.getPlayer()); - Assert.assertEquals("testing", j.getCell()); - - StringBuilder sb = new StringBuilder(); - for(String s : j.getReason()) { - sb.append(s).append(' '); - } - - sb.deleteCharAt(sb.length() - 1); - - Assert.assertEquals("This is a reason", sb.toString()); - } -} \ No newline at end of file diff --git a/src/test/java/test/java/com/graywolf336/jail/TestJewelCommands.java b/src/test/java/test/java/com/graywolf336/jail/TestJewelCommands.java new file mode 100644 index 0000000..67039bb --- /dev/null +++ b/src/test/java/test/java/com/graywolf336/jail/TestJewelCommands.java @@ -0,0 +1,49 @@ +package test.java.com.graywolf336.jail; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.graywolf336.jail.command.commands.jewels.Jailing; +import com.graywolf336.jail.command.commands.jewels.Transfer; +import com.lexicalscope.jewel.cli.CliFactory; + +public class TestJewelCommands { + @Test + public void testJailJewel() { + String[] args = { "--player", "graywolf336", "-c", "testing", "-r", "This", "is", "a", "reason" }; + Jailing j = CliFactory.parseArguments(Jailing.class, args); + + Assert.assertEquals("graywolf336", j.getPlayer()); + Assert.assertEquals("testing", j.getCell()); + + StringBuilder sb = new StringBuilder(); + for(String s : j.getReason()) { + sb.append(s).append(' '); + } + + sb.deleteCharAt(sb.length() - 1); + + Assert.assertEquals("This is a reason", sb.toString()); + } + + @Test + public void testTransferForJailAndCell() { + String[] args = { "-p", "graywolf336", "-j", "hardcore", "-c", "cell_n01" }; + Transfer t = CliFactory.parseArguments(Transfer.class, args); + + Assert.assertEquals("The player parsed is not what we expected.", "graywolf336", t.getPlayer()); + Assert.assertEquals("The jail parsed is not what we expected.", "hardcore", t.getJail()); + Assert.assertEquals("The cell parsed is not what we expected.", "cell_n01", t.getCell()); + } + + @Test + public void testTransferForNoCell() { + String[] args = { "-p", "graywolf336", "-j", "hardcore" }; + Transfer t = CliFactory.parseArguments(Transfer.class, args); + + Assert.assertEquals("The player parsed is not what we expected.", "graywolf336", t.getPlayer()); + Assert.assertEquals("The jail parsed is not what we expected.", "hardcore", t.getJail()); + Assert.assertNull("The cell is not null?", t.getCell()); + } +} \ No newline at end of file