2020-04-08 15:00:29 -05:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "gmock-Account.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct _MockAccountClass
|
|
|
|
{
|
|
|
|
QofInstanceClass parent_class;
|
|
|
|
};
|
|
|
|
typedef struct _MockAccountClass MockAccountClass;
|
|
|
|
|
2020-09-20 15:33:51 -05:00
|
|
|
G_DEFINE_TYPE(MockAccount, gnc_mockaccount, QOF_TYPE_INSTANCE);
|
2020-04-08 15:00:29 -05:00
|
|
|
|
|
|
|
static void
|
2020-09-20 15:33:51 -05:00
|
|
|
gnc_mockaccount_init (MockAccount *inst)
|
2020-04-08 15:00:29 -05:00
|
|
|
{
|
2020-06-03 16:36:48 -05:00
|
|
|
// function is unused, initialization is done in the MockAccount's C++ constructor
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-09-20 15:33:51 -05:00
|
|
|
gnc_mockaccount_class_init(MockAccountClass *klass)
|
2020-04-08 15:00:29 -05:00
|
|
|
{
|
|
|
|
// function is unused, class functions are defined in C++ code
|
|
|
|
}
|
|
|
|
|
2020-09-22 15:07:21 -05:00
|
|
|
|
|
|
|
GType gnc_account_get_type(void)
|
|
|
|
{
|
|
|
|
return gnc_mockaccount_get_type();
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:00:29 -05:00
|
|
|
void
|
|
|
|
xaccAccountBeginEdit (Account *account)
|
|
|
|
{
|
2020-09-20 15:33:51 -05:00
|
|
|
ASSERT_TRUE(GNC_IS_MOCKACCOUNT(account));
|
2020-09-20 17:47:53 -05:00
|
|
|
gnc_mockaccount(account)->begin_edit();
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xaccAccountCommitEdit (Account *account)
|
|
|
|
{
|
2020-09-20 15:33:51 -05:00
|
|
|
ASSERT_TRUE(GNC_IS_MOCKACCOUNT(account));
|
2020-09-20 17:47:53 -05:00
|
|
|
gnc_mockaccount(account)->commit_edit();
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QofBook *
|
|
|
|
gnc_account_get_book(const Account *account)
|
|
|
|
{
|
2020-09-20 17:47:53 -05:00
|
|
|
SCOPED_TRACE("");
|
2020-10-05 15:48:52 -05:00
|
|
|
auto mockaccount = gnc_mockaccount(account);
|
2020-09-20 17:47:53 -05:00
|
|
|
return mockaccount ? mockaccount->get_book() : nullptr;
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc,
|
|
|
|
void *data)
|
|
|
|
{
|
2020-09-20 17:47:53 -05:00
|
|
|
SCOPED_TRACE("");
|
2020-10-05 15:48:52 -05:00
|
|
|
auto mockaccount = gnc_mockaccount(acc);
|
2020-09-20 17:47:53 -05:00
|
|
|
return mockaccount ? mockaccount->for_each_transaction(proc, data) : 0;
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GncImportMatchMap *
|
|
|
|
gnc_account_imap_create_imap (Account *acc)
|
|
|
|
{
|
2020-09-20 17:47:53 -05:00
|
|
|
SCOPED_TRACE("");
|
2020-10-05 15:48:52 -05:00
|
|
|
auto mockaccount = gnc_mockaccount(acc);
|
2020-09-20 17:47:53 -05:00
|
|
|
return mockaccount ? mockaccount->create_imap() : nullptr;
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Account*
|
|
|
|
gnc_account_imap_find_account (
|
|
|
|
GncImportMatchMap *imap,
|
|
|
|
const char* category,
|
|
|
|
const char *key)
|
|
|
|
{
|
2020-07-09 14:36:01 -05:00
|
|
|
return ((GncMockImportMatchMap*)imap)->find_account(category, key);
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gnc_account_imap_add_account (
|
|
|
|
GncImportMatchMap *imap,
|
|
|
|
const char *category,
|
|
|
|
const char *key,
|
|
|
|
Account *acc)
|
|
|
|
{
|
2020-07-09 14:36:01 -05:00
|
|
|
((GncMockImportMatchMap*)imap)->add_account(category, key, acc);
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Account*
|
|
|
|
gnc_account_imap_find_account_bayes (
|
|
|
|
GncImportMatchMap *imap,
|
|
|
|
GList *tokens)
|
|
|
|
{
|
2020-06-02 01:16:50 -05:00
|
|
|
std::vector<const char*> tokenVec;
|
2020-04-08 15:00:29 -05:00
|
|
|
|
|
|
|
for (auto token = tokens; token; token = token->next)
|
|
|
|
{
|
|
|
|
tokenVec.push_back(static_cast <char const *> (token->data));
|
|
|
|
}
|
|
|
|
|
2020-07-09 14:36:01 -05:00
|
|
|
return ((GncMockImportMatchMap*)imap)->find_account_bayes(tokenVec);
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gnc_account_imap_add_account_bayes (
|
|
|
|
GncImportMatchMap *imap,
|
|
|
|
GList *tokens,
|
|
|
|
Account *acc)
|
|
|
|
{
|
2020-06-02 01:16:50 -05:00
|
|
|
std::vector<const char*> tokenVec;
|
2020-04-08 15:00:29 -05:00
|
|
|
|
|
|
|
for (auto token = tokens; token; token = token->next)
|
|
|
|
{
|
|
|
|
tokenVec.push_back(static_cast <char const *> (token->data));
|
|
|
|
}
|
|
|
|
|
2020-07-09 14:36:01 -05:00
|
|
|
((GncMockImportMatchMap*)imap)->add_account_bayes(tokenVec, acc);
|
2020-04-08 15:00:29 -05:00
|
|
|
}
|
|
|
|
|