From 5ece29e5d714d9e7d67a761c8e02c1a6073293c5 Mon Sep 17 00:00:00 2001 From: Goesta Date: Tue, 14 Feb 2017 21:19:47 +0100 Subject: [PATCH] Added assertNotType test assertion --- .../base/impl/CardTestPlayerAPIImpl.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 8892244611..3d819e72d3 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -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()); }