File indexing completed on 2025-01-05 04:55:02
0001 #include <QTest> 0002 #include <QDebug> 0003 #include <sink/test.h> 0004 #include <sink/store.h> 0005 #include <sink/resourcecontrol.h> 0006 0007 #include "entitycontroller.h" 0008 #include "entitymodel.h" 0009 0010 class EntityControllerTest : public QObject 0011 { 0012 Q_OBJECT 0013 private slots: 0014 0015 void initTestCase() 0016 { 0017 Sink::Test::initTest(); 0018 } 0019 0020 void testCreate() 0021 { 0022 Sink::ApplicationDomain::DummyResource::create("account1"); 0023 0024 using namespace Sink::ApplicationDomain; 0025 auto account = ApplicationDomainType::createEntity<SinkAccount>(); 0026 Sink::Store::create(account).exec().waitForFinished(); 0027 0028 auto resource = Sink::ApplicationDomain::DummyResource::create(account.identifier()); 0029 Sink::Store::create(resource).exec().waitForFinished(); 0030 0031 EntityController controller; 0032 controller.create({ 0033 {"type", "calendar"}, 0034 {"account", account.identifier()}, 0035 {"entity", QVariantMap { 0036 {"name", "name2"} 0037 } 0038 } 0039 }); 0040 0041 0042 Sink::ResourceControl::flushMessageQueue(resource.identifier()).exec().waitForFinished(); 0043 0044 { 0045 const auto calendars = Sink::Store::read<Sink::ApplicationDomain::Calendar>({}); 0046 QCOMPARE(calendars.size(), 1); 0047 QCOMPARE(calendars.first().getName(), QLatin1String{"name2"}); 0048 } 0049 } 0050 }; 0051 0052 QTEST_MAIN(EntityControllerTest) 0053 #include "entitycontrollertest.moc"