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; +}; +