source: src/test/model/eventtest.cpp @ 5a73d27

qt5
Last change on this file since 5a73d27 was 5a73d27, checked in by komarma <komarma@…>, 12 years ago

Adding orm module

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#include "eventtest.h"
2
3#include <QtTest>
4#include <QSqlDatabase>
5
6#include <QDebug>
7
8#include <event.h>
9
10void EventTest::initTestCase()
11{
12    // Connect to the test database. Ask Mr. Pavelka to generate one for you :)
13    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
14    db.setDatabaseName("fostem-test.sqlite");
15    QVERIFY(db.open());
16}
17
18void EventTest::getById()
19{
20    Event event = Event::getById(500, 1);
21    QCOMPARE(event.id(), 500);
22    QCOMPARE(event.start(), QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
23    QCOMPARE(event.activityId(), 123);
24
25    // !!! TODO: typeId and languageId
26    QCOMPARE(event.typeId(), 0);
27    QCOMPARE(event.languageId(), 0);
28}
29
30void EventTest::colNames()
31{
32    QCOMPARE(Event::colName(Event::Id), QString("id"));
33    QCOMPARE(Event::colName(Event::Conference), QString("xid_conference"));
34    QCOMPARE(Event::colName(Event::Start), QString("start"));
35    QCOMPARE(Event::colName(Event::Duration), QString("duration"));
36    QCOMPARE(Event::colName(Event::Activity), QString("xid_activity"));
37    QCOMPARE(Event::colName(Event::Type), QString("type"));
38    QCOMPARE(Event::colName(Event::Language), QString("language"));
39}
40
41void EventTest::storingValues()
42{
43    Event event;
44    QCOMPARE(event.id(), 0);
45
46    event.setId(10);
47    QCOMPARE(event.id(), 10);
48
49    event.setConferenceId(20);
50    QCOMPARE(event.conferenceId(), 20);
51
52    event.setStart(QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
53    QCOMPARE(event.start(), QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
54
55    event.setDuration(30);
56    QCOMPARE(event.duration(), 30);
57
58    event.setActivityId(40);
59    QCOMPARE(event.activityId(), 40);
60
61    event.setTypeId(50);
62    QCOMPARE(event.typeId(), 50);
63
64    event.setLanguageId(60);
65    QCOMPARE(event.languageId(), 60);
66}
Note: See TracBrowser for help on using the repository browser.