GnuCash  4.11-627-g58c1a51897
Public Member Functions | Data Fields
QofFakeQuery Class Reference

Fake object providing functionality similar to QofQuery. More...

#include <fake-qofquery.h>

Public Member Functions

 QofFakeQuery (QofIdTypeConst obj_type)
 MOCK_METHOD1 (set_book, void(QofBook *))
 MOCK_METHOD5 (add_date_match_tt, void(gboolean, time64, gboolean, time64, QofQueryOp))
 MOCK_METHOD2 (add_single_account_match, void(Account *, QofQueryOp))
 MOCK_METHOD0 (run, std::vector< void *>())

Data Fields

QofIdTypeConst m_obj_type

Detailed Description

Fake object providing functionality similar to QofQuery.

QofQuery is a typedef for struct _QofQuery, which is not public. Therefore class QofFakeQuery is not derived from QofQuery.

To use a QofFakeQuery object simply create it before the GnuCash code performs a query. Check that the QofFakeQuery object is created with the correct object type. Also define all expectations and return values on the created QofFakeQuery object before the GnuCash code performs the query.

After the query is finished, the QofFakeQuery object can be destroyed. A QofFakeQuery object can only be used once.

Internally each created QofFakeQuery object is registered at a QofFakeQueryPool, which provides it to the GnuCash code on request. This pool observes the life-cycle of each QofFakeQuery object. The following steps are expected to be done on each QofFakeQuery object in the specified order:

  1. create QofFakeQuery object (test application)
  2. call qof_query_create_for() (GnuCash code)
  3. call qof_query_run() (GnuCash code)
  4. call qof_query_destroy() (GnuCash code)
  5. destroy QofFakeQuery object (test application)

The calls to qof_query_create_for(), qof_query_run() and qof_query_destroy() are optional, but

Several GTest assertions are implemented to signal violations of the QofFakeQuery object life-cycle.

If you want to check, that a certain query is run by the GnuCash code, then define the appropriate expectations on the QofFakeQuery object in your test application.

Definition at line 57 of file fake-qofquery.h.

The documentation for this class was generated from the following files: