Changeset 20a6010 for src/test


Ignore:
Timestamp:
12/30/09 14:50:23 (13 years ago)
Author:
komarma <komarma@…>
Branches:
master, qt5
Children:
489f262
Parents:
5a73d27
Message:

Adding database loading and data conversion to orm module

Location:
src/test/model
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/test/model/eventtest.cpp

    r5a73d27 r20a6010  
    1212    // Connect to the test database. Ask Mr. Pavelka to generate one for you :)
    1313    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    14     db.setDatabaseName("fostem-test.sqlite");
     14    db.setDatabaseName("fosdem-test.sqlite");
    1515    QVERIFY(db.open());
    1616}
     
    2828}
    2929
    30 void 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 
    4130void EventTest::storingValues()
    4231{
    4332    Event event;
    44     QCOMPARE(event.id(), 0);
    4533
    4634    event.setId(10);
     35    event.setConferenceId(20);
     36    event.setStart(QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
     37    event.setDuration(30);
     38    event.setActivityId(40);
     39    event.setTypeId(50);
     40    event.setLanguageId(60);
     41
    4742    QCOMPARE(event.id(), 10);
    48 
    49     event.setConferenceId(20);
    5043    QCOMPARE(event.conferenceId(), 20);
    51 
    52     event.setStart(QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
    5344    QCOMPARE(event.start(), QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
    54 
    55     event.setDuration(30);
    5645    QCOMPARE(event.duration(), 30);
    57 
    58     event.setActivityId(40);
    5946    QCOMPARE(event.activityId(), 40);
    60 
    61     event.setTypeId(50);
    6247    QCOMPARE(event.typeId(), 50);
    63 
    64     event.setLanguageId(60);
    6548    QCOMPARE(event.languageId(), 60);
    6649}
     50
     51
     52void EventTest::hydrate()
     53{
     54    QSqlRecord record;
     55    record.append(QSqlField("duration", QVariant::Int));
     56    record.append(QSqlField("id", QVariant::Int));
     57    record.setValue(0, 10);
     58    record.setValue(1, 20);
     59
     60    Event event = Event::hydrate(record);
     61    QCOMPARE(event.id(), 20);
     62    QCOMPARE(event.duration(), 10);
     63}
     64
     65void EventTest::columnsForSelect()
     66{
     67    QCOMPARE(Event::columnsForSelect(), QString("id,xid_conference,start,duration,xid_activity,type,language"));
     68    QCOMPARE(Event::columnsForSelect("t0"),
     69             QString("t0.id,t0.xid_conference,t0.start,t0.duration,t0.xid_activity,t0.type,t0.language"));
     70}
     71
     72void EventTest::selectQuery()
     73{
     74    QCOMPARE(Event::selectQuery(), QString("SELECT id,xid_conference,start,duration,xid_activity,type,language FROM event "));
     75}
  • src/test/model/eventtest.h

    r5a73d27 r20a6010  
    1212
    1313    void getById();
    14     void colNames();
    1514    void storingValues();
     15    void hydrate();
     16    void columnsForSelect();
     17    void selectQuery();
    1618};
    1719
Note: See TracChangeset for help on using the changeset viewer.