mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Initial test setup
This commit is contained in:
parent
954ce9577f
commit
22770a3ac4
71
gnucash/import-export/test/gtest-import-backend.cpp
Normal file
71
gnucash/import-export/test/gtest-import-backend.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include <config.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <import-backend.h>
|
||||
}
|
||||
|
||||
#include "gmock-qofbook.h"
|
||||
#include "gmock-Account.h"
|
||||
#include "gmock-Transaction.h"
|
||||
#include "gmock-Split.h"
|
||||
|
||||
|
||||
|
||||
/* Global test environment */
|
||||
|
||||
class TestEnvironment : public testing::Environment
|
||||
{
|
||||
public:
|
||||
void SetUp()
|
||||
{
|
||||
m_book = new QofMockBook;
|
||||
};
|
||||
|
||||
void TearDown()
|
||||
{
|
||||
m_book->free();
|
||||
};
|
||||
|
||||
QofMockBook* m_book;
|
||||
};
|
||||
|
||||
testing::Environment* const env = testing::AddGlobalTestEnvironment(new TestEnvironment);
|
||||
|
||||
|
||||
|
||||
class ImportBackendTest : public testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
m_import_acc = new MockAccount();
|
||||
m_dest_acc = new MockAccount();
|
||||
m_trans = new MockTransaction();
|
||||
m_split = new MockSplit();
|
||||
|
||||
using namespace testing;
|
||||
|
||||
// define behaviour of m_import_acc
|
||||
ON_CALL(*m_import_acc, getBook())
|
||||
.WillByDefault(Return(((TestEnvironment*)env)->m_book));
|
||||
}
|
||||
|
||||
void TearDown()
|
||||
{
|
||||
m_import_acc->free();
|
||||
m_dest_acc->free();
|
||||
m_trans->free();
|
||||
m_split->free();
|
||||
}
|
||||
|
||||
MockAccount* m_import_acc;
|
||||
MockAccount* m_dest_acc;
|
||||
MockTransaction* m_trans;
|
||||
MockSplit* m_split;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user