import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.assertFalse; public class CoinsTest { @Test public void test_getCoinAmount(){ Coins coin = new Coins(10); assertTrue(coin.getCoinAmount() >= 0); } @Test public void test_addCoinException(){ try { Coins coin = new Coins(10); coin.addCoin(-10); fail("Erwartet NegativAmountException - addCoin"); }catch (NegativAmountException negativAmountException) { assertTrue(negativAmountException.getMessage().equals("Es kann kein negativer amount an Coins hinzugefügt werden")); } } @Test public void test_removeCoinException(){ try { Coins coin = new Coins(10); coin.removeCoin(-10); fail("Erwartet NegativAmountException - removeCoin"); }catch (NegativAmountException negativAmountException) { assertTrue(negativAmountException.getMessage().equals("Es kann kein negativer amount an Coins hinzugefügt werden")); } } @Test public void test_removeCoin(){ Coins coin = new Coins(10); try { assertTrue(coin.removeCoin(10)); } catch (NegativAmountException e) { e.printStackTrace(); } } @Test public void test_changeCoinAmount_true(){ Coins coin = new Coins(10); try { assertTrue(coin.changeCoinAmmount(10)); } catch (NegativAmountException e) { e.printStackTrace(); } } @Test public void test_changeCoinAmount_false(){ Coins coin = new Coins(9); try { assertTrue(coin.changeCoinAmmount(7)); } catch (NegativAmountException e) { e.printStackTrace(); } } }