From 2d71a5a016da6614bb9a320c014ae51b5b0b973c Mon Sep 17 00:00:00 2001 From: fdai7430 Date: Sat, 4 Feb 2023 18:58:25 +0100 Subject: [PATCH] unittest: Added test for getRunawayChance() --- .../org/bitbiome/commands/UseCommandTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/org/bitbiome/commands/UseCommandTest.java b/src/test/java/org/bitbiome/commands/UseCommandTest.java index 0cc69d3..343c1b5 100644 --- a/src/test/java/org/bitbiome/commands/UseCommandTest.java +++ b/src/test/java/org/bitbiome/commands/UseCommandTest.java @@ -2,6 +2,8 @@ package org.bitbiome.commands; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.ArrayList; + import org.bitbiome.classes.TravelEngine; import org.bitbiome.entities.Item; import org.bitbiome.entities.Mob; @@ -9,6 +11,30 @@ import org.bitbiome.entities.Player; import org.junit.jupiter.api.Test; public class UseCommandTest { + @Test + public void testGetRunawayChance() { + UseCommand com = new UseCommand(); + assertEquals(10, com.getRunawayChance()); + ArrayList enemies = new ArrayList(); + enemies.add(new Mob("Wolf", false, 11, 10)); + com.getEnemies(enemies); + assertEquals(17, com.getRunawayChance()); + enemies.add(new Mob("Drache", false, 55, 20)); + com.getEnemies(enemies); + assertEquals(41, com.getRunawayChance()); + enemies.add(new Mob("Drache", false, 55, 20)); + enemies.add(new Mob("Drache", false, 55, 20)); + enemies.add(new Mob("Drache", false, 55, 20)); + enemies.add(new Mob("Drache", false, 55, 20)); + enemies.add(new Mob("Drache", false, 55, 20)); + com.getEnemies(enemies); + assertEquals(96, com.getRunawayChance()); + enemies = new ArrayList(); + enemies.add(new Mob("Cthulhu", false, 15000, 10000)); + com.getEnemies(enemies); + assertEquals(100, com.getRunawayChance()); + } + @Test public void testUseItemMob() { UseCommand com = new UseCommand();