From 22770a3ac42d8c63bd5f87fbb18a6e33a2cf5944 Mon Sep 17 00:00:00 2001 From: Christian Gruber Date: Wed, 8 Apr 2020 22:08:46 +0200 Subject: [PATCH] Initial test setup --- .../test/gtest-import-backend.cpp | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 gnucash/import-export/test/gtest-import-backend.cpp diff --git a/gnucash/import-export/test/gtest-import-backend.cpp b/gnucash/import-export/test/gtest-import-backend.cpp new file mode 100644 index 0000000000..1ee3e2d4c9 --- /dev/null +++ b/gnucash/import-export/test/gtest-import-backend.cpp @@ -0,0 +1,71 @@ +#include +#include +#include + +#include + +extern "C" +{ +#include +} + +#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; +}; +