void MyMoneyInstitutionTest::testMyMoneyFileConstructor() { MyMoneyInstitution *t = new MyMoneyInstitution("GUID", *n); CPPUNIT_ASSERT(t->id() == "GUID"); CPPUNIT_ASSERT(t->street() == "street"); CPPUNIT_ASSERT(t->town() == "town"); CPPUNIT_ASSERT(t->postcode() == "postcode"); CPPUNIT_ASSERT(t->telephone() == "telephone"); CPPUNIT_ASSERT(t->manager() == "manager"); CPPUNIT_ASSERT(t->name() == "name"); CPPUNIT_ASSERT(t->sortcode() == "sortcode"); delete t; }
void MyMoneyInstitutionTest::testReadXML() { MyMoneyInstitution i; QString ref_ok = QString( "<!DOCTYPE TEST>\n" "<INSTITUTION-CONTAINER>\n" " <INSTITUTION sortcode=\"sortcode\" id=\"I00001\" manager=\"manager\" name=\"name\" >\n" " <ADDRESS street=\"street\" zip=\"postcode\" city=\"town\" telephone=\"telephone\" />\n" " <ACCOUNTIDS>\n" " <ACCOUNTID id=\"A000001\" />\n" " <ACCOUNTID id=\"A000003\" />\n" " </ACCOUNTIDS>\n" " <KEYVALUEPAIRS>\n" " <PAIR key=\"key\" value=\"value\" />\n" " </KEYVALUEPAIRS>\n" " </INSTITUTION>\n" "</INSTITUTION-CONTAINER>\n"); QString ref_false = QString( "<!DOCTYPE TEST>\n" "<INSTITUTION-CONTAINER>\n" " <KINSTITUTION sortcode=\"sortcode\" id=\"I00001\" manager=\"manager\" name=\"name\" >\n" " <ADDRESS street=\"street\" zip=\"postcode\" city=\"town\" telephone=\"telephone\" />\n" " <ACCOUNTIDS>\n" " <ACCOUNTID id=\"A000001\" />\n" " <ACCOUNTID id=\"A000003\" />\n" " </ACCOUNTIDS>\n" " </KINSTITUTION>\n" "</INSTITUTION-CONTAINER>\n"); QDomDocument doc; QDomElement node; doc.setContent(ref_false); node = doc.documentElement().firstChild().toElement(); try { i = MyMoneyInstitution(node); CPPUNIT_FAIL("Missing expected exception"); } catch(MyMoneyException *e) { delete e; } i.addAccountId("TEST"); doc.setContent(ref_ok); node = doc.documentElement().firstChild().toElement(); try { QStringList alist; alist << "A000001" << "A000003"; i = MyMoneyInstitution(node); CPPUNIT_ASSERT(i.sortcode() == "sortcode"); CPPUNIT_ASSERT(i.id() == "I00001"); CPPUNIT_ASSERT(i.manager() == "manager"); CPPUNIT_ASSERT(i.name() == "name"); CPPUNIT_ASSERT(i.street() == "street"); CPPUNIT_ASSERT(i.postcode() == "postcode"); CPPUNIT_ASSERT(i.city() == "town"); CPPUNIT_ASSERT(i.telephone() == "telephone"); CPPUNIT_ASSERT(i.accountList() == alist); CPPUNIT_ASSERT(i.value(QString("key")) == "value"); } catch(MyMoneyException *e) { delete e; CPPUNIT_FAIL("Unexpected exception"); } }