Changeset View
Changeset View
Standalone View
Standalone View
tests/units/akonadi/akonadicontextrepositorytest.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 109 | { | |||
---|---|---|---|---|---|
110 | // GIVEN | 110 | // GIVEN | ||
111 | Akonadi::Item contextItem; | 111 | Akonadi::Item contextItem; | ||
112 | contextItem.setId(42); | 112 | contextItem.setId(42); | ||
113 | auto context = Domain::Context::Ptr::create(); | 113 | auto context = Domain::Context::Ptr::create(); | ||
114 | 114 | | |||
115 | // A mock job | 115 | // A mock job | ||
116 | auto contextItemDeleteJob = new FakeJob(this); | 116 | auto contextItemDeleteJob = new FakeJob(this); | ||
117 | 117 | | |||
118 | // Storage mock returning the mock job | | |||
119 | Utils::MockObject<Akonadi::StorageInterface> storageMock; | 118 | Utils::MockObject<Akonadi::StorageInterface> storageMock; | ||
120 | storageMock(&Akonadi::StorageInterface::removeItem).when(contextItem) | 119 | Utils::MockObject<Akonadi::SerializerInterface> serializerMock; | ||
120 | QScopedPointer<Akonadi::ContextRepository> repository(new Akonadi::ContextRepository(storageMock.getInstance(), | ||||
121 | serializerMock.getInstance())); | ||||
122 | | ||||
123 | // Storage mock returning the mock job | ||||
124 | storageMock(&Akonadi::StorageInterface::removeItem).when(contextItem, repository.get()) | ||||
121 | .thenReturn(contextItemDeleteJob); | 125 | .thenReturn(contextItemDeleteJob); | ||
122 | 126 | | |||
123 | // Serializer mock | 127 | // Serializer mock | ||
124 | Utils::MockObject<Akonadi::SerializerInterface> serializerMock; | | |||
125 | serializerMock(&Akonadi::SerializerInterface::createItemFromContext).when(context).thenReturn(contextItem); | 128 | serializerMock(&Akonadi::SerializerInterface::createItemFromContext).when(context).thenReturn(contextItem); | ||
126 | 129 | | |||
127 | // WHEN | 130 | // WHEN | ||
128 | QScopedPointer<Akonadi::ContextRepository> repository(new Akonadi::ContextRepository(storageMock.getInstance(), | | |||
129 | serializerMock.getInstance())); | | |||
130 | repository->remove(context)->exec(); | 131 | repository->remove(context)->exec(); | ||
131 | 132 | | |||
132 | // THEN | 133 | // THEN | ||
133 | QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromContext).when(context).exactly(1)); | 134 | QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromContext).when(context).exactly(1)); | ||
134 | QVERIFY(storageMock(&Akonadi::StorageInterface::removeItem).when(contextItem).exactly(1)); | 135 | QVERIFY(storageMock(&Akonadi::StorageInterface::removeItem).when(contextItem, repository.get()).exactly(1)); | ||
135 | } | 136 | } | ||
136 | 137 | | |||
137 | void shouldAssociateATaskToAContext_data() | 138 | void shouldAssociateATaskToAContext_data() | ||
138 | { | 139 | { | ||
139 | QTest::addColumn<Akonadi::Item>("associatedContextItem"); | 140 | QTest::addColumn<Akonadi::Item>("associatedContextItem"); | ||
140 | QTest::addColumn<Akonadi::Item>("item"); | 141 | QTest::addColumn<Akonadi::Item>("item"); | ||
141 | QTest::addColumn<Domain::Context::Ptr>("context"); | 142 | QTest::addColumn<Domain::Context::Ptr>("context"); | ||
142 | QTest::addColumn<Domain::Task::Ptr>("task"); | 143 | QTest::addColumn<Domain::Task::Ptr>("task"); | ||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |