mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Added assertNotType test assertion
This commit is contained in:
parent
10284642bc
commit
5ece29e5d7
1 changed files with 26 additions and 10 deletions
|
@ -703,22 +703,24 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param subType a subtype to test for
|
||||
*/
|
||||
public void assertType(String cardName, CardType type, String subType) throws AssertionError {
|
||||
Permanent found = null;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getName().equals(cardName)) {
|
||||
found = permanent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
|
||||
|
||||
Permanent found = getPermanent(cardName);
|
||||
Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', found.getCardType().contains(type));
|
||||
if (subType != null) {
|
||||
Assert.assertTrue("(Battlefield) card sub-type not equal (" + cardName + ':' + subType + ')', found.getSubtype(currentGame).contains(subType));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert whether a permanent is not a specified type
|
||||
*
|
||||
* @param cardName Name of the permanent that should be checked.
|
||||
* @param type A type to test for
|
||||
*/
|
||||
public void assertNotType(String cardName, CardType type) throws AssertionError {
|
||||
Permanent found = getPermanent(cardName);
|
||||
Assert.assertFalse("(Battlefield) card type found (" + cardName + ':' + type + ')', found.getCardType().contains(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert whether a permanent is tapped or not
|
||||
*
|
||||
|
@ -922,6 +924,20 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
Assert.assertEquals("message", currentGame.getState().getActivePlayerId(), player.getId());
|
||||
}
|
||||
|
||||
public Permanent getPermanent(String cardName) {
|
||||
Permanent found = null;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getName().equals(cardName)) {
|
||||
found = permanent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertNotNull("Couldn't find a card with specified name: " + cardName, found);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public Permanent getPermanent(String cardName, Player player) {
|
||||
return getPermanent(cardName, player.getId());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue