Merge pull request #1375 from poixen/mana_cleanup

Mana updates
This commit is contained in:
LevelX2 2015-11-19 22:37:14 +01:00
commit f4871fe489
2 changed files with 107 additions and 26 deletions

View file

@ -434,6 +434,8 @@ public class ManaTest {
@Test
public void shouldNotSubtractLessThan0() {
// given
expectedException.expect(ArithmeticException.class);
expectedException.expectMessage("You can not subtract below 0");
Mana thisMana = new Mana(2, 2, 2, 2, 2, 2, 2);
Mana thatMana = new Mana(10, 1, 1, 1, 10, 1, 1);
@ -441,13 +443,57 @@ public class ManaTest {
thisMana.subtract(thatMana);
// then
assertEquals(-8, thisMana.getRed());
assertEquals(1, thisMana.getGreen());
assertEquals(1, thisMana.getBlue());
assertEquals(1, thisMana.getWhite());
assertEquals(-8, thisMana.getBlack());
assertEquals(1, thisMana.getColorless());
assertEquals(1, thisMana.getAny());
}
@Test
public void shouldNotAllowMinusSubtractionCost() {
// given
expectedException.expect(ArithmeticException.class);
expectedException.expectMessage("You can not subtract below 0");
Mana thisMana = new Mana(2, 2, 2, 2, 2, 2, 2);
Mana thatMana = new Mana(10, 1, 1, 1, 10, 1, 1);
// when
thisMana.subtractCost(thatMana);
// then
}
@Test
public void shouldUseExistingManaToPayColorless() {
// given
Mana available = new Mana();
available.setRed(7);
Mana cost = new Mana();
cost.setRed(4);
cost.setColorless(2);
// when
available.subtractCost(cost);
// then
assertEquals(1, available.getRed());
}
@Test
public void shouldThrowExceptionOnUnavailableColorless() {
// given
expectedException.expect(ArithmeticException.class);
expectedException.expectMessage("Not enough mana to pay colorless");
Mana available = new Mana();
available.setRed(4);
Mana cost = new Mana();
cost.setRed(4);
cost.setColorless(2);
// when
available.subtractCost(cost);
}