diff --git a/tests/carddatabase/carddatabase_test.cpp b/tests/carddatabase/carddatabase_test.cpp index 059bb8e54..833365345 100644 --- a/tests/carddatabase/carddatabase_test.cpp +++ b/tests/carddatabase/carddatabase_test.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,44 @@ TEST(CardDatabaseTest, EmptyLoadedSnapshotIsReadyNotLoading) EXPECT_EQ(NotLoaded, db.getLoadStatus()); } +TEST(CardInfoTest, ContinuumIdentityAndStatsHaveNativeAndLegacyPropertyAccess) +{ + auto native = CardInfo::newInstance("Native Continuum Card"); + native->setProperty("identity", "The Shadow Queen"); + native->setProperty("attack", "10"); + native->setProperty("armour", "3"); + native->setProperty("health", "12"); + + EXPECT_EQ(native->getIdentity(), "The Shadow Queen"); + EXPECT_EQ(native->getAttack(), "10"); + EXPECT_EQ(native->getArmour(), "3"); + EXPECT_EQ(native->getHealth(), "12"); + EXPECT_EQ(native->getAtkHp(), "10/12"); + EXPECT_EQ(native->getPowTough(), "10/12"); // Legacy accessor remains useful. + + auto legacyMse = CardInfo::newInstance("Legacy Continuum Card"); + legacyMse->setProperty("alias", "The Guardian"); + legacyMse->setProperty("strength", "9"); + legacyMse->setProperty("armor", "4"); + legacyMse->setProperty("health", "8"); + EXPECT_EQ(legacyMse->getIdentity(), "The Guardian"); + EXPECT_EQ(legacyMse->getAttack(), "9"); + EXPECT_EQ(legacyMse->getArmour(), "4"); + EXPECT_EQ(legacyMse->getHealth(), "8"); + EXPECT_EQ(legacyMse->getAtkHp(), "9/8"); + + auto oldPt = CardInfo::newInstance("Old Imported Card"); + oldPt->setProperty(Mtg::PowTough, "2/7"); + EXPECT_EQ(oldPt->getAttack(), "2"); + EXPECT_EQ(oldPt->getHealth(), "7"); + EXPECT_EQ(oldPt->getAtkHp(), "2/7"); + + // Missing values should not be represented as false zeroes. + auto blank = CardInfo::newInstance("No Stats"); + EXPECT_TRUE(blank->getAtkHp().isEmpty()); + EXPECT_TRUE(blank->getArmour().isEmpty()); +} + TEST(CardDatabaseTest, LazyPropertiesHashStreamsBlobAccessors) { QHash props;