You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kmymoney/kmymoney2/mymoney/mymoneypayeetest.cpp

77 lines
2.8 KiB

/***************************************************************************
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(){
TQDomDocument doc;
TQDomElement tqparent = doc.createElement("Test");
doc.appendChild(tqparent);
MyMoneyPayee payee1;
payee1.m_id = "some random id";//if the ID isn't set, w ethrow an exception
payee1.writeXML(doc,tqparent);
TQString temp1 = "Account1";
payee1.setDefaultAccountId(temp1);
payee1.writeXML(doc,tqparent);
TQString temp2 = "Account2";
payee1.setDefaultAccountId(temp2);
payee1.writeXML(doc,tqparent);
payee1.setDefaultAccountId();
payee1.writeXML(doc,tqparent);
TQDomElement el = tqparent.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());
TQString 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());
}