blob: 601679cfc44be075493d9d8e3cd08457d846e156 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/***************************************************************************
mymoneypayeetest.cpp
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "mymoneypayeetest.h"
#include <iostream>
#include <fstream>
using namespace std;
MyMoneyPayeeTest:: MyMoneyPayeeTest () {
}
void MyMoneyPayeeTest::setUp () {
}
void MyMoneyPayeeTest::tearDown () {
}
void MyMoneyPayeeTest::testXml(){
QDomDocument doc;
QDomElement parent = doc.createElement("Test");
doc.appendChild(parent);
MyMoneyPayee payee1;
payee1.m_id = "some random id";//if the ID isn't set, w ethrow an exception
payee1.writeXML(doc,parent);
QString temp1 = "Account1";
payee1.setDefaultAccountId(temp1);
payee1.writeXML(doc,parent);
QString temp2 = "Account2";
payee1.setDefaultAccountId(temp2);
payee1.writeXML(doc,parent);
payee1.setDefaultAccountId();
payee1.writeXML(doc,parent);
QDomElement el = parent.firstChild().toElement();
CPPUNIT_ASSERT(!el.isNull());
MyMoneyPayee payee2(el);
CPPUNIT_ASSERT(!payee2.defaultAccountEnabled());
CPPUNIT_ASSERT(payee2.defaultAccountId().isEmpty());
el = el.nextSibling().toElement();
CPPUNIT_ASSERT(!el.isNull());
MyMoneyPayee payee3(el);
CPPUNIT_ASSERT(payee3.defaultAccountEnabled());
CPPUNIT_ASSERT(payee3.defaultAccountId()==temp1);
el = el.nextSibling().toElement();
CPPUNIT_ASSERT(!el.isNull());
MyMoneyPayee payee4(el);
CPPUNIT_ASSERT(payee4.defaultAccountEnabled());
CPPUNIT_ASSERT(payee4.defaultAccountId()==temp2);
el = el.nextSibling().toElement();
CPPUNIT_ASSERT(!el.isNull());
MyMoneyPayee payee5(el);
CPPUNIT_ASSERT(!payee5.defaultAccountEnabled());
CPPUNIT_ASSERT(payee5.defaultAccountId().isEmpty());
}
void MyMoneyPayeeTest::testDefaultAccount(){
MyMoneyPayee payee;
CPPUNIT_ASSERT(!payee.defaultAccountEnabled());
CPPUNIT_ASSERT(payee.defaultAccountId().isEmpty());
QString temp = "Account1";
payee.setDefaultAccountId(temp);
CPPUNIT_ASSERT(payee.defaultAccountEnabled());
CPPUNIT_ASSERT(payee.defaultAccountId()==temp);
payee.setDefaultAccountId();
CPPUNIT_ASSERT(!payee.defaultAccountEnabled());
CPPUNIT_ASSERT(payee.defaultAccountId().isEmpty());
}
|