Add unit test for version command
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 15 Jan 2017 12:35:54 +0000 (13:35 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 15 Jan 2017 12:35:54 +0000 (13:35 +0100)
src/test/kotlin/net/pterodactylus/sone/fcp/VersionCommandTest.kt [new file with mode: 0644]

diff --git a/src/test/kotlin/net/pterodactylus/sone/fcp/VersionCommandTest.kt b/src/test/kotlin/net/pterodactylus/sone/fcp/VersionCommandTest.kt
new file mode 100644 (file)
index 0000000..e54e7aa
--- /dev/null
@@ -0,0 +1,29 @@
+package net.pterodactylus.sone.fcp
+
+import net.pterodactylus.sone.core.Core
+import net.pterodactylus.sone.main.SonePlugin
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.equalTo
+import org.junit.Test
+
+/**
+ * Unit test for [VersionCommand].
+ */
+class VersionCommandTest : SoneCommandTest() {
+
+       override fun createCommand(core: Core) = VersionCommand(core)
+
+       @Test
+       fun `command does not require write access`() {
+               assertThat(command.requiresWriteAccess(), equalTo(false))
+       }
+
+       @Test
+       fun `command replies with the correct version information`() {
+               val replyParameters = command.execute(parameters).replyParameters
+               assertThat(replyParameters["Message"], equalTo("Version"))
+               assertThat(replyParameters["Version"], equalTo(SonePlugin.getPluginVersion().toString()))
+               assertThat(replyParameters["ProtocolVersion"], equalTo("1"))
+       }
+
+}