From 56ce1abb4483424f2a8c6bbaa98a143e8b17787f Mon Sep 17 00:00:00 2001 From: Clint Herron Date: Sun, 23 Apr 2017 04:36:01 +0200 Subject: [PATCH] Unit tests for Blood Moon + Urborg interaction (#3216) * Adding unit tests for Blood Moon + Urborg, Tomb of Yawgmoth interaction as per issue #3072 and #2957. These tests fail expected, confirming those bug reports. * Re-adding line that was accidentally deleted from other unit test. * Cleaning up unit tests a bit more and removing leftover code I had missed the first time. --- .../LandTypeChangingEffectsTest.java | 62 +++++++++++++++++++ .../base/impl/CardTestPlayerAPIImpl.java | 13 ++++ 2 files changed, 75 insertions(+) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/LandTypeChangingEffectsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/LandTypeChangingEffectsTest.java index fbd8bc1b63..e297a91159 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/LandTypeChangingEffectsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/LandTypeChangingEffectsTest.java @@ -32,6 +32,7 @@ import mage.constants.CardType; import mage.constants.PhaseStep; import mage.constants.Zone; import mage.counters.CounterType; +import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -128,7 +129,68 @@ public class LandTypeChangingEffectsTest extends CardTestPlayerBase { assertCounterCount("Forbidding Watchtower", CounterType.FLOOD, 1); assertType("Forbidding Watchtower", CardType.LAND, "Island"); assertPowerToughness(playerB, "Forbidding Watchtower", 1, 5); + } + + String urborgtoy = "Urborg, Tomb of Yawgmoth"; + String bloodmoon = "Blood Moon"; + String canopyvista = "Canopy Vista"; + @Test + public void testBloodMoonBeforeUrborg() { + // Blood Moon 2R + // Enchantment + // Nonbasic lands are Mountains + addCard(Zone.HAND, playerA, bloodmoon); + // Each land is a Swamp in addition to its other land types. + addCard(Zone.HAND, playerA, urborgtoy); + + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + + addCard(Zone.BATTLEFIELD, playerB, canopyvista, 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bloodmoon); + playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, urborgtoy); + + setStopAt(2, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertPermanentCount(playerA, bloodmoon, 1); + assertPermanentCount(playerA, urborgtoy, 1); + assertType(canopyvista, CardType.LAND, "Mountain"); + assertNotSubtype(canopyvista, "Island"); + assertNotSubtype(canopyvista, "Swamp"); + assertType(urborgtoy, CardType.LAND, "Mountain"); + assertNotSubtype(urborgtoy, "Swamp"); + Assert.assertTrue("The mana the land can produce should be [{R}] but it's " + playerB.getManaAvailable(currentGame).toString(), playerB.getManaAvailable(currentGame).toString().equals("[{R}]")); + } + + @Test + public void testBloodMoonAfterUrborg() { + // Blood Moon 2R + // Enchantment + // Nonbasic lands are Mountains + addCard(Zone.HAND, playerA, bloodmoon); + // Each land is a Swamp in addition to its other land types. + addCard(Zone.HAND, playerA, urborgtoy); + + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + + addCard(Zone.BATTLEFIELD, playerB, canopyvista, 1); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, urborgtoy); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, bloodmoon); + + setStopAt(2, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertPermanentCount(playerA, bloodmoon, 1); + assertPermanentCount(playerA, urborgtoy, 1); + assertType(canopyvista, CardType.LAND, "Mountain"); + assertNotSubtype(canopyvista, "Island"); + assertNotSubtype(canopyvista, "Swamp"); + assertType(urborgtoy, CardType.LAND, "Mountain"); + assertNotSubtype(urborgtoy, "Swamp"); + Assert.assertTrue("The mana the land can produce should be [{R}] but it's " + playerB.getManaAvailable(currentGame).toString(), playerB.getManaAvailable(currentGame).toString().equals("[{R}]")); } } 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 0d3b5adf83..639fadf80c 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 @@ -720,6 +720,19 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement Permanent found = getPermanent(cardName); Assert.assertFalse("(Battlefield) card type found (" + cardName + ':' + type + ')', found.getCardType().contains(type)); } + + /** + * Assert whether a permanent is not a specified subtype + * + * @param cardName Name of the permanent that should be checked. + * @param subType a subtype to test for + */ + public void assertNotSubtype(String cardName, String subType) throws AssertionError { + Permanent found = getPermanent(cardName); + if (subType != null) { + Assert.assertFalse("(Battlefield) card sub-type equal (" + cardName + ':' + subType + ')', found.getSubtype(currentGame).contains(subType)); + } + } /** * Assert whether a permanent is tapped or not