source: src/test/mvc/eventtest.cpp @ 6df32f2

qt5
Last change on this file since 6df32f2 was 6df32f2, checked in by gregor herrmann <gregoa@…>, 10 years ago

Update GPL blurb in source files.

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[ca90cb1]1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 *
[6df32f2]4 * This file is part of ConfClerk.
[ca90cb1]5 *
[6df32f2]6 * ConfClerk is free software: you can redistribute it and/or modify it
[ca90cb1]7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 2 of the License, or (at your option)
9 * any later version.
10 *
[6df32f2]11 * ConfClerk is distributed in the hope that it will be useful, but
[ca90cb1]12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
[6df32f2]17 * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
[ca90cb1]18 */
[e5bc908]19#include "eventtest.h"
20
21#include <QtTest>
22#include <QSqlDatabase>
23
[5a73d27]24#include <QDebug>
25
[e5bc908]26#include <event.h>
27
28void EventTest::initTestCase()
29{
30    // Connect to the test database. Ask Mr. Pavelka to generate one for you :)
31    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
[20a6010]32    db.setDatabaseName("fosdem-test.sqlite");
[e5bc908]33    QVERIFY(db.open());
34}
35
36void EventTest::getById()
37{
38    Event event = Event::getById(500, 1);
[489f262]39
[e5bc908]40    QCOMPARE(event.id(), 500);
[489f262]41    QCOMPARE(event.start(), QDateTime(QDate(2009, 2, 7), QTime(11, 30, 0), Qt::UTC));
[4693fa6]42    QCOMPARE(event.trackId(), 123);
[e5bc908]43
44    // !!! TODO: typeId and languageId
[489f262]45    QCOMPARE(event.type(), QString("Podium"));
46    QCOMPARE(event.language(), QString("English"));
[e5bc908]47}
[5a73d27]48
[d0d0a66]49void EventTest::getByDate()
50{
51    QCOMPARE(Event::getByDate(QDate(2009, 2, 7), 1).count(), 127);
52    QCOMPARE(Event::getByDate(QDate(2009, 2, 8), 1).count(), 154);
53}
54
[5a73d27]55void EventTest::storingValues()
56{
57    Event event;
58
59    event.setId(10);
60    event.setConferenceId(20);
61    event.setStart(QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
62    event.setDuration(30);
[4693fa6]63    event.setTrackId(40);
[489f262]64    event.setType(QString("type"));
65    event.setLanguage(QString("language"));
[20a6010]66
67    QCOMPARE(event.id(), 10);
68    QCOMPARE(event.conferenceId(), 20);
69    QCOMPARE(event.start(), QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
70    QCOMPARE(event.duration(), 30);
[4693fa6]71    QCOMPARE(event.trackId(), 40);
[489f262]72    QCOMPARE(event.type(), QString("type"));
73    QCOMPARE(event.language(), QString("language"));
[5a73d27]74}
[20a6010]75
76void EventTest::hydrate()
77{
78    QSqlRecord record;
79    record.append(QSqlField("duration", QVariant::Int));
80    record.append(QSqlField("id", QVariant::Int));
81    record.setValue(0, 10);
82    record.setValue(1, 20);
83
84    Event event = Event::hydrate(record);
85    QCOMPARE(event.id(), 20);
86    QCOMPARE(event.duration(), 10);
87}
88
89void EventTest::columnsForSelect()
90{
[4693fa6]91    QCOMPARE(Event::columnsForSelect(), QString("id,xid_conference,start,duration,xid_track,type,language"));
[20a6010]92    QCOMPARE(Event::columnsForSelect("t0"),
[4693fa6]93             QString("t0.id,t0.xid_conference,t0.start,t0.duration,t0.xid_track,t0.type,t0.language"));
[20a6010]94}
95
96void EventTest::selectQuery()
97{
[4693fa6]98    QCOMPARE(Event::selectQuery(), QString("SELECT id,xid_conference,start,duration,xid_track,type,language FROM event "));
[20a6010]99}
Note: See TracBrowser for help on using the repository browser.