Revision 4cde82a2
Von Christian Ehringfeld vor mehr als 8 Jahren hinzugefügt
src/cache.cpp | ||
---|---|---|
return;
|
||
}
|
||
}
|
||
//this->cache.insert(key, entity.toWeakRef());
|
||
this->cache.insert(key, entity.toWeakRef());
|
||
}
|
||
}
|
||
|
tests/em/tst_em.cpp | ||
---|---|---|
#include "tst_em.h"
|
||
|
||
void EmTest::initTestCase() {
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Group>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Article>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Employee>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<WorkerGroup>();
|
||
this->e = new CuteEntityManager::EntityManager("QSQLITE",
|
||
":memory:", "", "", "", "", true, "foreign_keys = ON", false);
|
||
}
|
||
//void EmTest::initTestCase() {
|
||
// CuteEntityManager::EntityInstanceFactory::registerClass<Group>();
|
||
// CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
|
||
// CuteEntityManager::EntityInstanceFactory::registerClass<Article>();
|
||
// CuteEntityManager::EntityInstanceFactory::registerClass<Employee>();
|
||
// CuteEntityManager::EntityInstanceFactory::registerClass<WorkerGroup>();
|
||
// this->e = new CuteEntityManager::EntityManager("QSQLITE",
|
||
// ":memory:", "", "", "", "", true, "foreign_keys = ON", false);
|
||
//}
|
||
|
||
void EmTest::cleanupTestCase() {
|
||
if (this->e) {
|
||
delete this->e;
|
||
this->e = nullptr;
|
||
}
|
||
}
|
||
//void EmTest::cleanupTestCase() {
|
||
// if (this->e) {
|
||
// delete this->e;
|
||
// this->e = nullptr;
|
||
// }
|
||
//}
|
||
|
||
void EmTest::testCheckDuplicates() {
|
||
QSharedPointer<Article> article = QSharedPointer<Article>(new Article(10,
|
||
... | ... | |
}
|
||
|
||
void EmTest::init() {
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Group>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Article>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Employee>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<WorkerGroup>();
|
||
this->e = new CuteEntityManager::EntityManager("QSQLITE",
|
||
":memory:", "", "", "", "", true, "foreign_keys = ON", false);
|
||
QStringList inits = QStringList() << "Person" << "Group" << "Article";
|
||
QVERIFY2(this->e->startup("emTestA", inits), "Failure");
|
||
auto migrations = this->e->findAll<CuteEntityManager::DatabaseMigration>();
|
||
... | ... | |
QVERIFY(!tableNames.contains("article"));
|
||
QVERIFY(!tableNames.contains("person_groups"));
|
||
QVERIFY(this->e->removeAll("cuteentitymanager::databasemigration"));
|
||
if (this->e) {
|
||
delete this->e;
|
||
this->e = nullptr;
|
||
}
|
||
}
|
||
|
||
void EmTest::testRelationTableCreation() {
|
||
... | ... | |
}
|
||
}
|
||
|
||
void EmTest::testNonCachedInheritedRelations()
|
||
{
|
||
void EmTest::testNonCachedInheritedRelations() {
|
||
QSharedPointer<Employee> e1 = QSharedPointer<Employee>(new Employee(42, "Fenja", "S.",
|
||
Person::Gender::FEMALE, "Lotta", QDate(1990, 10, 10), "Psychology"));
|
||
QSharedPointer<Employee> e2 = QSharedPointer<Employee>(new Employee(11, "Janine",
|
||
... | ... | |
} catch(QString e) {
|
||
QFAIL(e.toUtf8().constData());
|
||
}
|
||
|
||
}
|
||
|
||
void EmTest::createRelationTables() {
|
tests/em/tst_em.h | ||
---|---|---|
Q_OBJECT
|
||
|
||
private Q_SLOTS:
|
||
void initTestCase();
|
||
void cleanupTestCase();
|
||
// void initTestCase();
|
||
// void cleanupTestCase();
|
||
void testCheckDuplicates();
|
||
void testBasics();
|
||
void init();
|
tests/em/tst_querybuilder.cpp | ||
---|---|---|
QCOMPARE(p->getNickName(), QString("Lotta"));
|
||
QCOMPARE(p->getGroups().size(), 2);
|
||
QVERIFY(p->getGroups().first());
|
||
QVERIFY(p->getGroups().first()->getPersons().last());
|
||
QCOMPARE(p->getGroups().first()->getPersons().size(),1);
|
||
QCOMPARE(p->getGroups().first()->getPersons().last()->getFamilyName(), QString("Sey."));
|
||
}
|
||
|
||
... | ... | |
QList<QSharedPointer<Group>> groupList = e->find<Group>(q, false, false);
|
||
QCOMPARE(groupList.size(), 2);
|
||
QCOMPARE(groupList.at(0)->getName(), QString("Group Health"));
|
||
//should be with cache 1 and without cache 0
|
||
QCOMPARE(groupList.at(0)->getPersons().size(), 1);
|
||
}
|
||
|
Auch abrufbar als: Unified diff
fixes