Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/tests/mymoneyfile-test.cpp
Show All 37 Lines | |||||
38 | #include "mymoneypayee.h" | 38 | #include "mymoneypayee.h" | ||
39 | #include "mymoneyenums.h" | 39 | #include "mymoneyenums.h" | ||
40 | #include "onlinejob.h" | 40 | #include "onlinejob.h" | ||
41 | 41 | | |||
42 | #include "payeeidentifier/ibanbic/ibanbic.h" | 42 | #include "payeeidentifier/ibanbic/ibanbic.h" | ||
43 | #include "payeeidentifier/payeeidentifierloader.h" | 43 | #include "payeeidentifier/payeeidentifierloader.h" | ||
44 | #include "payeeidentifiertyped.h" | 44 | #include "payeeidentifiertyped.h" | ||
45 | 45 | | |||
46 | #include "mymoneystoragenames.h" | | |||
47 | using namespace MyMoneyStandardAccounts; | | |||
48 | | ||||
49 | QTEST_GUILESS_MAIN(MyMoneyFileTest) | 46 | QTEST_GUILESS_MAIN(MyMoneyFileTest) | ||
50 | 47 | | |||
51 | MyMoneyFileTest::MyMoneyFileTest() : | 48 | MyMoneyFileTest::MyMoneyFileTest() : | ||
52 | m(nullptr), | 49 | m(nullptr), | ||
53 | storage(nullptr) | 50 | storage(nullptr) | ||
54 | { | 51 | { | ||
55 | } | 52 | } | ||
56 | 53 | | |||
▲ Show 20 Lines • Show All 1311 Lines • ▼ Show 20 Line(s) | |||||
1368 | 1365 | | |||
1369 | } | 1366 | } | ||
1370 | 1367 | | |||
1371 | void MyMoneyFileTest::testSetAccountName() | 1368 | void MyMoneyFileTest::testSetAccountName() | ||
1372 | { | 1369 | { | ||
1373 | MyMoneyFileTransaction ft; | 1370 | MyMoneyFileTransaction ft; | ||
1374 | clearObjectLists(); | 1371 | clearObjectLists(); | ||
1375 | try { | 1372 | try { | ||
1376 | m->setAccountName(stdAccNames[stdAccLiability], "Verbindlichkeiten"); | 1373 | m->setAccountName(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Liability), "Verbindlichkeiten"); | ||
1377 | ft.commit(); | 1374 | ft.commit(); | ||
1378 | QCOMPARE(m_objectsRemoved.count(), 0); | 1375 | QCOMPARE(m_objectsRemoved.count(), 0); | ||
1379 | QCOMPARE(m_objectsModified.count(), 1); | 1376 | QCOMPARE(m_objectsModified.count(), 1); | ||
1380 | QCOMPARE(m_objectsAdded.count(), 0); | 1377 | QCOMPARE(m_objectsAdded.count(), 0); | ||
1381 | QCOMPARE(m_balanceChanged.count(), 0); | 1378 | QCOMPARE(m_balanceChanged.count(), 0); | ||
1382 | QCOMPARE(m_valueChanged.count(), 0); | 1379 | QCOMPARE(m_valueChanged.count(), 0); | ||
1383 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Liability"))); | 1380 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Liability"))); | ||
1384 | 1381 | | |||
1385 | } catch (const MyMoneyException &) { | 1382 | } catch (const MyMoneyException &) { | ||
1386 | QFAIL("Unexpected exception"); | 1383 | QFAIL("Unexpected exception"); | ||
1387 | } | 1384 | } | ||
1388 | ft.restart(); | 1385 | ft.restart(); | ||
1389 | clearObjectLists(); | 1386 | clearObjectLists(); | ||
1390 | try { | 1387 | try { | ||
1391 | m->setAccountName(stdAccNames[stdAccAsset], QString::fromUtf8("Vermögen")); | 1388 | m->setAccountName(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Asset), QString::fromUtf8("Vermögen")); | ||
1392 | ft.commit(); | 1389 | ft.commit(); | ||
1393 | QCOMPARE(m_objectsRemoved.count(), 0); | 1390 | QCOMPARE(m_objectsRemoved.count(), 0); | ||
1394 | QCOMPARE(m_objectsModified.count(), 1); | 1391 | QCOMPARE(m_objectsModified.count(), 1); | ||
1395 | QCOMPARE(m_objectsAdded.count(), 0); | 1392 | QCOMPARE(m_objectsAdded.count(), 0); | ||
1396 | QCOMPARE(m_balanceChanged.count(), 0); | 1393 | QCOMPARE(m_balanceChanged.count(), 0); | ||
1397 | QCOMPARE(m_valueChanged.count(), 0); | 1394 | QCOMPARE(m_valueChanged.count(), 0); | ||
1398 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Asset"))); | 1395 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Asset"))); | ||
1399 | 1396 | | |||
1400 | } catch (const MyMoneyException &) { | 1397 | } catch (const MyMoneyException &) { | ||
1401 | QFAIL("Unexpected exception"); | 1398 | QFAIL("Unexpected exception"); | ||
1402 | } | 1399 | } | ||
1403 | ft.restart(); | 1400 | ft.restart(); | ||
1404 | clearObjectLists(); | 1401 | clearObjectLists(); | ||
1405 | try { | 1402 | try { | ||
1406 | m->setAccountName(stdAccNames[stdAccExpense], "Ausgaben"); | 1403 | m->setAccountName(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Expense), "Ausgaben"); | ||
1407 | ft.commit(); | 1404 | ft.commit(); | ||
1408 | QCOMPARE(m_objectsRemoved.count(), 0); | 1405 | QCOMPARE(m_objectsRemoved.count(), 0); | ||
1409 | QCOMPARE(m_objectsModified.count(), 1); | 1406 | QCOMPARE(m_objectsModified.count(), 1); | ||
1410 | QCOMPARE(m_objectsAdded.count(), 0); | 1407 | QCOMPARE(m_objectsAdded.count(), 0); | ||
1411 | QCOMPARE(m_balanceChanged.count(), 0); | 1408 | QCOMPARE(m_balanceChanged.count(), 0); | ||
1412 | QCOMPARE(m_valueChanged.count(), 0); | 1409 | QCOMPARE(m_valueChanged.count(), 0); | ||
1413 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Expense"))); | 1410 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Expense"))); | ||
1414 | 1411 | | |||
1415 | } catch (const MyMoneyException &) { | 1412 | } catch (const MyMoneyException &) { | ||
1416 | QFAIL("Unexpected exception"); | 1413 | QFAIL("Unexpected exception"); | ||
1417 | } | 1414 | } | ||
1418 | ft.restart(); | 1415 | ft.restart(); | ||
1419 | clearObjectLists(); | 1416 | clearObjectLists(); | ||
1420 | try { | 1417 | try { | ||
1421 | m->setAccountName(stdAccNames[stdAccIncome], "Einnahmen"); | 1418 | m->setAccountName(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Income), "Einnahmen"); | ||
1422 | ft.commit(); | 1419 | ft.commit(); | ||
1423 | QCOMPARE(m_objectsRemoved.count(), 0); | 1420 | QCOMPARE(m_objectsRemoved.count(), 0); | ||
1424 | QCOMPARE(m_objectsModified.count(), 1); | 1421 | QCOMPARE(m_objectsModified.count(), 1); | ||
1425 | QCOMPARE(m_objectsAdded.count(), 0); | 1422 | QCOMPARE(m_objectsAdded.count(), 0); | ||
1426 | QCOMPARE(m_balanceChanged.count(), 0); | 1423 | QCOMPARE(m_balanceChanged.count(), 0); | ||
1427 | QCOMPARE(m_valueChanged.count(), 0); | 1424 | QCOMPARE(m_valueChanged.count(), 0); | ||
1428 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Income"))); | 1425 | QVERIFY(m_objectsModified.contains(QLatin1String("AStd::Income"))); | ||
1429 | 1426 | | |||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 1561 | { | |||
1573 | t.setMemo("Memotext"); | 1570 | t.setMemo("Memotext"); | ||
1574 | 1571 | | |||
1575 | MyMoneySplit split1; | 1572 | MyMoneySplit split1; | ||
1576 | MyMoneySplit split2; | 1573 | MyMoneySplit split2; | ||
1577 | 1574 | | |||
1578 | split1.setAccountId("A000001"); | 1575 | split1.setAccountId("A000001"); | ||
1579 | split1.setShares(MyMoneyMoney(-1000, 100)); | 1576 | split1.setShares(MyMoneyMoney(-1000, 100)); | ||
1580 | split1.setValue(MyMoneyMoney(-1000, 100)); | 1577 | split1.setValue(MyMoneyMoney(-1000, 100)); | ||
1581 | split2.setAccountId(stdAccNames[stdAccExpense]); | 1578 | split2.setAccountId(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Expense)); | ||
1582 | split2.setValue(MyMoneyMoney(1000, 100)); | 1579 | split2.setValue(MyMoneyMoney(1000, 100)); | ||
1583 | split2.setShares(MyMoneyMoney(1000, 100)); | 1580 | split2.setShares(MyMoneyMoney(1000, 100)); | ||
1584 | try { | 1581 | try { | ||
1585 | t.addSplit(split1); | 1582 | t.addSplit(split1); | ||
1586 | t.addSplit(split2); | 1583 | t.addSplit(split2); | ||
1587 | } catch (const MyMoneyException &) { | 1584 | } catch (const MyMoneyException &) { | ||
1588 | QFAIL("Unexpected exception!"); | 1585 | QFAIL("Unexpected exception!"); | ||
1589 | } | 1586 | } | ||
▲ Show 20 Lines • Show All 1249 Lines • Show Last 20 Lines |