Files
Cockatrice/tests/carddatabase/carddatabase_test.cpp
BruebachL d31b044529 [Card DB] Split out database loading and querying from main class (#6175)
* Simplify add card.

Took 25 minutes

Took 8 minutes

# Commit time for manual adjustment:
# Took 16 minutes

Took 7 seconds

* Refactor out db loading from card db.

Took 39 minutes

Took 9 minutes

Took 2 minutes


Took 17 seconds

* Refactor out db queries from card db.

Took 42 minutes

* Lint.

Took 3 minutes

* I guess.

Took 7 minutes

* Tests.

Took 15 minutes

* I don't understand this.

Took 9 minutes

* fix linker errors

* Rename to querier and promote to QObject

Took 39 minutes

* Lint.

Took 3 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2025-09-27 00:27:15 +02:00

39 lines
1.4 KiB
C++

#include "mocks.h"
#include "gtest/gtest.h"
namespace
{
TEST(CardDatabaseTest, LoadXml)
{
settingsCache = new SettingsCache;
CardDatabase *db = new CardDatabase;
// ensure the card database is empty at start
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty at start";
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty at start";
ASSERT_EQ(0, db->query()->getAllMainCardTypes().size()) << "Types not empty at start";
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status at start";
// load dummy cards and test result
db->loadCardDatabases();
ASSERT_EQ(9, db->getCardList().size()) << "Wrong card count after load";
ASSERT_EQ(5, db->getSetList().size()) << "Wrong sets count after load";
ASSERT_EQ(3, db->query()->getAllMainCardTypes().size()) << "Wrong types count after load";
ASSERT_EQ(Ok, db->getLoadStatus()) << "Wrong status after load";
// ensure the card database is empty after clear()
db->clear();
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty after clear";
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty after clear";
ASSERT_EQ(0, db->query()->getAllMainCardTypes().size()) << "Types not empty after clear";
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status after clear";
}
} // namespace
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}