Browse Source

unittest: test for collect Command

testIncreaseAmountOfPlayerConfig()
remotes/origin/Julia
Juliakn66 2 years ago
parent
commit
363112a364
  1. 26
      src/test/java/org/bitbiome/commands/CollectCommandTest.java

26
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);
}
}
Loading…
Cancel
Save