source: src/test/mvc/eventtest.cpp @ 4693fa6

qt5
Last change on this file since 4693fa6 was 4693fa6, checked in by pavelpa <pavelpa@…>, 12 years ago

changed 'Activity' -> 'Track'

  • Property mode set to 100644
File size: 2.2 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("fosdem-test.sqlite");
15    QVERIFY(db.open());
16}
17
18void EventTest::getById()
19{
20    Event event = Event::getById(500, 1);
21
22    QCOMPARE(event.id(), 500);
23    QCOMPARE(event.start(), QDateTime(QDate(2009, 2, 7), QTime(11, 30, 0), Qt::UTC));
24    QCOMPARE(event.trackId(), 123);
25
26    // !!! TODO: typeId and languageId
27    QCOMPARE(event.type(), QString("Podium"));
28    QCOMPARE(event.language(), QString("English"));
29}
30
31void EventTest::getByDate()
32{
33    QCOMPARE(Event::getByDate(QDate(2009, 2, 7), 1).count(), 127);
34    QCOMPARE(Event::getByDate(QDate(2009, 2, 8), 1).count(), 154);
35}
36
37void EventTest::storingValues()
38{
39    Event event;
40
41    event.setId(10);
42    event.setConferenceId(20);
43    event.setStart(QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
44    event.setDuration(30);
45    event.setTrackId(40);
46    event.setType(QString("type"));
47    event.setLanguage(QString("language"));
48
49    QCOMPARE(event.id(), 10);
50    QCOMPARE(event.conferenceId(), 20);
51    QCOMPARE(event.start(), QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
52    QCOMPARE(event.duration(), 30);
53    QCOMPARE(event.trackId(), 40);
54    QCOMPARE(event.type(), QString("type"));
55    QCOMPARE(event.language(), QString("language"));
56}
57
58void EventTest::hydrate()
59{
60    QSqlRecord record;
61    record.append(QSqlField("duration", QVariant::Int));
62    record.append(QSqlField("id", QVariant::Int));
63    record.setValue(0, 10);
64    record.setValue(1, 20);
65
66    Event event = Event::hydrate(record);
67    QCOMPARE(event.id(), 20);
68    QCOMPARE(event.duration(), 10);
69}
70
71void EventTest::columnsForSelect()
72{
73    QCOMPARE(Event::columnsForSelect(), QString("id,xid_conference,start,duration,xid_track,type,language"));
74    QCOMPARE(Event::columnsForSelect("t0"),
75             QString("t0.id,t0.xid_conference,t0.start,t0.duration,t0.xid_track,t0.type,t0.language"));
76}
77
78void EventTest::selectQuery()
79{
80    QCOMPARE(Event::selectQuery(), QString("SELECT id,xid_conference,start,duration,xid_track,type,language FROM event "));
81}
Note: See TracBrowser for help on using the repository browser.