File indexing completed on 2024-05-12 16:45:21
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 /** @file 0007 * This file is a test script. 0008 * 0009 * @author Stephane MANKOWSKI / Guillaume DE BURE 0010 */ 0011 #include "skgtestmacro.h" 0012 #include "skgbankincludes.h" 0013 #include "skgimportexportmanager.h" 0014 0015 /** 0016 * The main function of the unit test 0017 * @param argc the number of arguments 0018 * @param argv the list of arguments 0019 */ 0020 int main(int argc, char** argv) 0021 { 0022 Q_UNUSED(argc) 0023 Q_UNUSED(argv) 0024 0025 // Init test 0026 SKGINITTEST(true) { 0027 // Test import 304313 0028 SKGDocumentBank document1; 0029 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0030 SKGError err; 0031 { 0032 // Scope of the transaction 0033 SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err) 0034 0035 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/304313.kmy")); 0036 SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true) 0037 } 0038 } 0039 0040 { 0041 // Test import SKG 0042 SKGDocumentBank document1; 0043 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0044 SKGError err; 0045 { 0046 // Scope of the transaction 0047 SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err) 0048 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/advice.skg")); 0049 SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true) 0050 } 0051 0052 { 0053 // Scope of the transaction 0054 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy3/advice.kmy")); 0055 SKGTESTERROR(QStringLiteral("KMY.exportFile"), imp1.exportFile(), true) 0056 } 0057 } 0058 0059 { 0060 // Test import wallet 0061 SKGDocumentBank document1; 0062 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0063 SKGError err; 0064 { 0065 // Scope of the transaction 0066 SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err) 0067 0068 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy3/wallet.kmy")); 0069 SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true) 0070 } 0071 0072 { 0073 SKGAccountObject account(&document1); 0074 SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("Espece")), true) 0075 SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true) 0076 SKGBankObject bank; 0077 SKGTESTERROR(QStringLiteral("KMY.load"), account.getBank(bank), true) 0078 SKGTEST(QStringLiteral("KMY:getName"), bank.getName(), QLatin1String("")) 0079 } 0080 { 0081 SKGAccountObject account(&document1); 0082 SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("Courant")), true) 0083 SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true) 0084 SKGBankObject bank; 0085 SKGTESTERROR(QStringLiteral("KMY.load"), account.getBank(bank), true) 0086 SKGTEST(QStringLiteral("KMY:getName"), bank.getName(), QStringLiteral("KMYMONEY")) 0087 } 0088 } 0089 // End test 0090 SKGENDTEST() 0091 }