From 4cdc657c5acf484ca32e7704d978504754021b6d Mon Sep 17 00:00:00 2001
From: GregHib <greghib@users.noreply.github.com>
Date: Sun, 22 Dec 2024 18:10:01 +0000
Subject: [PATCH] Add tests

---
 .../activity/skill/thieving/PickpocketTest.kt | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 game/src/test/kotlin/world/gregs/voidps/world/activity/skill/thieving/PickpocketTest.kt

diff --git a/game/src/test/kotlin/world/gregs/voidps/world/activity/skill/thieving/PickpocketTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/activity/skill/thieving/PickpocketTest.kt
new file mode 100644
index 000000000..e5c1c66bd
--- /dev/null
+++ b/game/src/test/kotlin/world/gregs/voidps/world/activity/skill/thieving/PickpocketTest.kt
@@ -0,0 +1,51 @@
+package world.gregs.voidps.world.activity.skill.thieving
+
+import org.junit.jupiter.api.Assertions.assertTrue
+import org.junit.jupiter.api.Test
+import world.gregs.voidps.FakeRandom
+import world.gregs.voidps.engine.entity.character.player.skill.Skill
+import world.gregs.voidps.engine.inv.add
+import world.gregs.voidps.engine.inv.inventory
+import world.gregs.voidps.type.setRandom
+import world.gregs.voidps.world.interact.entity.effect.stunned
+import world.gregs.voidps.world.script.WorldTest
+import world.gregs.voidps.world.script.npcOption
+import kotlin.random.Random
+import kotlin.test.assertEquals
+import kotlin.test.assertFalse
+
+internal class PickpocketTest : WorldTest() {
+
+    @Test
+    fun `Successfully pickpocket`() {
+        setRandom(object : FakeRandom() {
+            override fun nextInt(until: Int) = 0
+        })
+        val player = createPlayer("thief", emptyTile)
+        val man = createNPC("man", emptyTile.addY(1))
+
+        player.npcOption(man, "Pickpocket")
+        tick(4)
+
+        assertEquals(player.inventory.count("coins"), 3)
+        assertEquals(player.experience.get(Skill.Thieving), 8.0)
+        assertFalse(player.stunned)
+    }
+
+    @Test
+    fun `Fail to pickpocket`() {
+        setRandom(object : FakeRandom() {
+            override fun nextInt(until: Int) = until
+        })
+        val player = createPlayer("thief", emptyTile)
+        val man = createNPC("man", emptyTile.addY(1))
+
+        player.npcOption(man, "Pickpocket")
+        tick(4)
+
+        assertEquals(player.inventory.count("coins"), 0)
+        assertEquals(player.experience.get(Skill.Thieving), 0.0)
+        assertTrue(player.stunned)
+    }
+
+}
\ No newline at end of file