Add user test
This commit is contained in:
parent
f41052337c
commit
02869cdf6e
3 changed files with 89 additions and 1 deletions
14
iFacilityTests/iFacilityTests.pro
Normal file
14
iFacilityTests/iFacilityTests.pro
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
CONFIG += qt console warn_on depend_includepath testcase
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += tst_ifacilitytest.cpp \
|
||||
..\iFacility\objects\profession.cpp \
|
||||
..\iFacility\objects\user.cpp
|
||||
|
||||
HEADERS += ..\iFacility\objects\profession.h \
|
||||
..\iFacility\objects\user.h
|
||||
73
iFacilityTests/tst_ifacilitytest.cpp
Normal file
73
iFacilityTests/tst_ifacilitytest.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#include <QtTest>
|
||||
|
||||
#include "../iFacility/objects/profession.h"
|
||||
#include "../iFacility/objects/user.h"
|
||||
|
||||
class iFacilityTest : public QObject {
|
||||
private:
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
iFacilityTest() = default;
|
||||
~iFacilityTest() = default;
|
||||
|
||||
private slots:
|
||||
void test_user_add_profession();
|
||||
void test_user_remove_profession();
|
||||
void test_user_current_profession();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
void iFacilityTest::test_user_add_profession() {
|
||||
auto u = User::createUser("test", "test", "f", "s", "t");
|
||||
|
||||
auto p1 = Profession::createProfession("test1");
|
||||
auto p2 = Profession::createProfession("test2");
|
||||
auto p3 = Profession::createProfession("test3");
|
||||
auto p4 = Profession::createProfession("test4");
|
||||
auto p5 = Profession::createProfession("test5");
|
||||
|
||||
u.addProfession(p1);
|
||||
QVERIFY(u.getProfessions().size() == 1);
|
||||
|
||||
u.addProfession(p1);
|
||||
QVERIFY(u.getProfessions().size() == 1);
|
||||
|
||||
u.addProfession(p2);
|
||||
u.addProfession(p3);
|
||||
u.addProfession(p4);
|
||||
u.addProfession(p5);
|
||||
QVERIFY(u.getProfessions().front() == p2);
|
||||
QVERIFY(u.getProfessions().back() == p5);
|
||||
}
|
||||
|
||||
void iFacilityTest::test_user_remove_profession() {
|
||||
auto u = User::createUser("test", "test", "f", "s", "t");
|
||||
|
||||
auto p1 = Profession::createProfession("test1");
|
||||
|
||||
u.addProfession(p1);
|
||||
QVERIFY(u.getProfessions().size() == 1);
|
||||
|
||||
u.removeProfession(p1);
|
||||
QVERIFY(u.getProfessions().isEmpty());
|
||||
}
|
||||
|
||||
void iFacilityTest::test_user_current_profession() {
|
||||
auto u = User::createUser("test", "test", "f", "s", "t");
|
||||
|
||||
auto p1 = Profession::createProfession("test1");
|
||||
auto p2 = Profession::createProfession("test2");
|
||||
|
||||
u.addProfession(p1);
|
||||
|
||||
QVERIFY(!u.setCurrentProfession(p2));
|
||||
QVERIFY(u.setCurrentProfession(p1));
|
||||
QVERIFY(u.getCurrentProfession() == p1.pID());
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(iFacilityTest)
|
||||
|
||||
#include "tst_ifacilitytest.moc"
|
||||
Loading…
Add table
Add a link
Reference in a new issue