1 /***************************************************************************
2  * SPDX-FileCopyrightText: 2021 S. MANKOWSKI stephane@mankowski.fr
3  * SPDX-FileCopyrightText: 2021 G. DE BURE support@mankowski.fr
4  * SPDX-License-Identifier: GPL-3.0-or-later
5  ***************************************************************************/
6 /** @file
7  * This file is a test script.
8  *
9  * @author Stephane MANKOWSKI / Guillaume DE BURE
10  */
11 #include "skgtestmacro.h"
12 #include "skgbankincludes.h"
13 #include "skgimportexportmanager.h"
14 
15 /**
16  * The main function of the unit test
17  * @param argc the number of arguments
18  * @param argv the list of arguments
19  */
main(int argc,char ** argv)20 int main(int argc, char** argv)
21 {
22     Q_UNUSED(argc)
23     Q_UNUSED(argv)
24 
25     // Init test
26     SKGINITTEST(true) {
27         // Test import 304313
28         SKGDocumentBank document1;
29         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
30         SKGError err;
31         {
32             // Scope of the transaction
33             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err)
34 
35             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/304313.kmy"));
36             SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true)
37         }
38     }
39 
40     {
41         // Test import SKG
42         SKGDocumentBank document1;
43         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
44         SKGError err;
45         {
46             // Scope of the transaction
47             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err)
48             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/advice.skg"));
49             SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true)
50         }
51 
52         {
53             // Scope of the transaction
54             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy3/advice.kmy"));
55             SKGTESTERROR(QStringLiteral("KMY.exportFile"), imp1.exportFile(), true)
56         }
57     }
58 
59     {
60         // Test import wallet
61         SKGDocumentBank document1;
62         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
63         SKGError err;
64         {
65             // Scope of the transaction
66             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err)
67 
68             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy3/wallet.kmy"));
69             SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true)
70         }
71 
72         {
73             SKGAccountObject account(&document1);
74             SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("Espece")), true)
75             SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true)
76             SKGBankObject bank;
77             SKGTESTERROR(QStringLiteral("KMY.load"), account.getBank(bank), true)
78             SKGTEST(QStringLiteral("KMY:getName"), bank.getName(), QLatin1String(""))
79         }
80         {
81             SKGAccountObject account(&document1);
82             SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("Courant")), true)
83             SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true)
84             SKGBankObject bank;
85             SKGTESTERROR(QStringLiteral("KMY.load"), account.getBank(bank), true)
86             SKGTEST(QStringLiteral("KMY:getName"), bank.getName(), QStringLiteral("KMYMONEY"))
87         }
88     }
89     // End test
90     SKGENDTEST()
91 }
92