From 363112a36472129b9f9cc88debc2b99c64e34537 Mon Sep 17 00:00:00 2001 From: Juliakn66 <117075450+Juliakn66@users.noreply.github.com> Date: Sat, 4 Feb 2023 13:47:31 +0100 Subject: [PATCH] unittest: test for collect Command testIncreaseAmountOfPlayerConfig() --- .../bitbiome/commands/CollectCommandTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/java/org/bitbiome/commands/CollectCommandTest.java diff --git a/src/test/java/org/bitbiome/commands/CollectCommandTest.java b/src/test/java/org/bitbiome/commands/CollectCommandTest.java new file mode 100644 index 0000000..cb718d1 --- /dev/null +++ b/src/test/java/org/bitbiome/commands/CollectCommandTest.java @@ -0,0 +1,26 @@ +package org.bitbiome.commands; + +import org.bitbiome.classes.JsonParser; +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.jupiter.api.Test; + + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class CollectCommandTest { + + @Test + public void testIncreaseAmountInPlayerConfig() { + CollectCommand command = new CollectCommand(); + JsonParser jp = new JsonParser(); + JSONObject o = jp.getJSONObject("playerconfig.json"); + JSONArray inventory = o.getJSONArray("inventory"); + int k = 0; + int initialAmount = inventory.getJSONObject(k).getInt("amount"); + command.increaseAmountInPlayerConfig(inventory, k, jp, o); + int finalAmount = inventory.getJSONObject(k).getInt("amount"); + assertEquals(initialAmount + 1, finalAmount); + } + +} \ No newline at end of file