Browse Source

unittest: testSubtractGold()

remotes/origin/shop
Max Gerbeth 2 years ago
parent
commit
e323599a74
  1. 2
      src/main/java/org/bitbiome/shop/Shop.java
  2. 10
      src/test/java/org/bitbiome/commands/ShopCommandTest.java

2
src/main/java/org/bitbiome/shop/Shop.java

@ -233,7 +233,7 @@ public class Shop {
System.out.println(""); System.out.println("");
} }
private int subtractGold(int gold, int cost){
public int subtractGold(int gold, int cost){
return gold - cost; return gold - cost;
} }
} }

10
src/test/java/org/bitbiome/commands/ShopCommandTest.java

@ -7,6 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class ShopCommandTest { public class ShopCommandTest {
final ShopCommand shopCommand = new ShopCommand(); final ShopCommand shopCommand = new ShopCommand();
final Shop shop = new Shop();
@Test @Test
public void testValidInput1(){ public void testValidInput1(){
boolean expected = true; boolean expected = true;
@ -31,4 +32,13 @@ public class ShopCommandTest {
boolean result = shopCommand.validInput("4"); boolean result = shopCommand.validInput("4");
assertEquals(expected, result); assertEquals(expected, result);
} }
@Test
public void testSubtractGold(){
int expected = 1;
int result = shop.subtractGold(3, 2);
assertEquals(expected, result);
}
} }
Loading…
Cancel
Save