34 #include <unittest-support.h>
35 #include "../Transaction.h"
37 #include "../Account.h"
38 #include "../SchedXaction.h"
39 #include "../gncCustomer.h"
40 #include "../gncEmployee.h"
41 #include "../gncJob.h"
42 #include "../gncVendor.h"
61 void test_suite_engine_kvp_properties (
void);
66 const gchar *suitename =
"/engine/kvp-properties";
69 setup_account (
Fixture *fixture, gconstpointer pData)
76 setup_trans (
Fixture *fixture, gconstpointer pData)
83 setup_split (
Fixture *fixture, gconstpointer pData)
90 setup_lot (
Fixture *fixture, gconstpointer pData)
93 fixture->lot = gnc_lot_new (book);
97 setup_customer (
Fixture *fixture, gconstpointer pData)
100 fixture->cust = gncCustomerCreate (book);
104 setup_employee (
Fixture *fixture, gconstpointer pData)
107 fixture->emp = gncEmployeeCreate (book);
111 setup_job (
Fixture *fixture, gconstpointer pData)
114 fixture->job = gncJobCreate (book);
118 setup_vendor (
Fixture *fixture, gconstpointer pData)
121 fixture->vend = gncVendorCreate (book);
125 teardown (
Fixture *fixture, gconstpointer pData)
131 test_destroy (fixture->acct);
136 test_account_kvp_properties (
Fixture *fixture, gconstpointer pData)
138 gint64 next_id = 12345678909876;
139 gint64 ab_acct_uid = 67890987654321;
140 gint64 next_id_r, ab_acct_uid_r;
141 gchar *online_id =
"my online id";
142 gchar *ab_acct_id =
"1234-5678-9087";
143 gchar *ab_bank_code =
"0032340";
144 gchar *online_id_r, *ab_acct_id_r, *ab_bank_code_r;
152 "lot-next-id", next_id,
153 "online-id", online_id,
154 "ofx-income-account", ofx_income_acct,
155 "ab-account-id", ab_acct_id,
156 "ab-bank-code", ab_bank_code,
157 "ab-account-uid", ab_acct_uid,
158 "ab-trans-retrieval", &trans_retr,
162 qof_instance_mark_clean (QOF_INSTANCE (fixture->acct));
165 "lot-next-id", &next_id_r,
166 "online-id", &online_id_r,
167 "ofx-income-account", &ofx_income_acct_r,
168 "ab-account-id", &ab_acct_id_r,
169 "ab-bank-code", &ab_bank_code_r,
170 "ab-account-uid", &ab_acct_uid_r,
171 "ab-trans-retrieval", &trans_retr_r,
173 g_assert_cmpint (next_id, ==, next_id_r);
174 g_assert_cmpstr (online_id, ==, online_id_r);
175 g_assert (
guid_equal (ofx_income_acct, ofx_income_acct_r));
176 g_assert_cmpstr (ab_acct_id, ==, ab_acct_id_r);
177 g_assert_cmpstr (ab_bank_code, ==, ab_bank_code_r);
178 g_assert_cmpint (ab_acct_uid, ==, ab_acct_uid_r);
184 test_trans_kvp_properties (
Fixture *fixture, gconstpointer pData)
188 GncGUID *invoice_r, *from_sx_r;
189 gchar *online_id =
"my online id";
195 "from-sched-xaction", from_sx,
196 "online-id", online_id,
200 qof_instance_mark_clean (QOF_INSTANCE (fixture->trans));
203 "invoice", &invoice_r,
204 "from-sched-xaction", &from_sx_r,
205 "online-id", &online_id_r,
209 g_assert_cmpstr (online_id, ==, online_id_r);
212 guid_free (invoice_r);
214 guid_free (from_sx_r);
215 g_free (online_id_r);
219 test_split_kvp_properties (
Fixture *fixture, gconstpointer pData)
221 gchar *debit_formula =
"e^xdydx";
222 gchar *credit_formula =
"seccostansin";
223 gchar *sx_shares =
"43";
224 gchar *online_id =
"my_online_id";
225 gchar *debit_formula_r, *credit_formula_r, *sx_shares_r;
229 gnc_numeric debit_numeric = gnc_numeric_create (123, 456);
230 gnc_numeric credit_numeric = gnc_numeric_create (789, 456);
235 "sx-debit-formula", debit_formula,
236 "sx-debit-numeric", &debit_numeric,
237 "sx-credit-formula", credit_formula,
238 "sx-credit-numeric", &credit_numeric,
239 "sx-account", sx_account,
240 "sx-shares", sx_shares,
241 "online-id", online_id,
245 qof_instance_mark_clean (QOF_INSTANCE (fixture->split));
248 "sx-debit-formula", &debit_formula_r,
249 "sx-debit-numeric", &debit_numeric_r,
250 "sx-credit-formula", &credit_formula_r,
251 "sx-credit-numeric", &credit_numeric_r,
252 "sx-account", &sx_account_r,
253 "sx-shares", &sx_shares_r,
254 "online-id", &online_id_r,
256 g_assert_cmpstr (debit_formula, ==, debit_formula_r);
258 g_assert_cmpstr (credit_formula, ==, credit_formula_r);
260 g_assert (
guid_equal (sx_account, sx_account_r));
261 g_assert_cmpstr (sx_shares, ==, sx_shares_r);
262 g_assert_cmpstr (online_id, ==, online_id_r);
264 g_free (debit_formula_r);
265 g_free (debit_numeric_r);
266 g_free (credit_formula_r);
267 g_free (credit_numeric_r);
270 "sx-credit-formula", NULL,
273 "sx-credit-formula", &credit_numeric_r,
275 g_assert (credit_numeric_r == NULL);
276 g_free (sx_shares_r);
277 g_free (online_id_r);
278 guid_free (sx_account);
279 guid_free (sx_account_r);
283 test_lot_kvp_properties (
Fixture *fixture, gconstpointer pData)
287 gint64 owner_type = 47;
295 GNC_OWNER_TYPE, owner_type,
296 GNC_OWNER_GUID, owner,
300 qof_instance_mark_clean (QOF_INSTANCE (fixture->lot));
303 "invoice", &invoice_r,
304 GNC_OWNER_TYPE, &owner_type_r,
305 GNC_OWNER_GUID, &owner_r,
308 g_assert_cmpint (owner_type, ==, owner_type_r);
312 guid_free (invoice_r);
318 test_customer_kvp_properties (
Fixture *fixture, gconstpointer pData)
320 gchar *pdf_dir =
"/foo/bar/baz";
324 GncGUID *inv_acct_r, *pmt_acct_r;
328 "export-pdf-dir", pdf_dir,
329 "invoice-last-posted-account", inv_acct,
330 "payment-last-account", pmt_acct,
334 qof_instance_mark_clean (QOF_INSTANCE (fixture->cust));
337 "export-pdf-dir", &pdf_dir_r,
338 "invoice-last-posted-account", &inv_acct_r,
339 "payment-last-account", &pmt_acct_r,
342 g_assert_cmpstr (pdf_dir, ==, pdf_dir_r);
345 guid_free (inv_acct);
346 guid_free (inv_acct_r);
347 guid_free (pmt_acct);
348 guid_free (pmt_acct_r);
354 test_employee_kvp_properties (
Fixture *fixture, gconstpointer pData)
356 gchar *pdf_dir =
"/foo/bar/baz";
360 GncGUID *inv_acct_r, *pmt_acct_r;
364 "export-pdf-dir", pdf_dir,
365 "invoice-last-posted-account", inv_acct,
366 "payment-last-account", pmt_acct,
370 qof_instance_mark_clean (QOF_INSTANCE (fixture->emp));
373 "export-pdf-dir", &pdf_dir_r,
374 "invoice-last-posted-account", &inv_acct_r,
375 "payment-last-account", &pmt_acct_r,
378 g_assert_cmpstr (pdf_dir, ==, pdf_dir_r);
381 guid_free (inv_acct);
382 guid_free (inv_acct_r);
383 guid_free (pmt_acct);
384 guid_free (pmt_acct_r);
390 test_job_kvp_properties (
Fixture *fixture, gconstpointer pData)
392 gchar *pdf_dir =
"/foo/bar/baz";
397 "export-pdf-dir", pdf_dir,
401 qof_instance_mark_clean (QOF_INSTANCE (fixture->job));
404 "export-pdf-dir", &pdf_dir_r,
407 g_assert_cmpstr (pdf_dir, ==, pdf_dir_r);
413 test_vendor_kvp_properties (
Fixture *fixture, gconstpointer pData)
415 gchar *pdf_dir =
"/foo/bar/baz";
419 GncGUID *inv_acct_r, *pmt_acct_r;
423 "export-pdf-dir", pdf_dir,
424 "invoice-last-posted-account", inv_acct,
425 "payment-last-account", pmt_acct,
429 qof_instance_mark_clean (QOF_INSTANCE (fixture->vend));
432 "export-pdf-dir", &pdf_dir_r,
433 "invoice-last-posted-account", &inv_acct_r,
434 "payment-last-account", &pmt_acct_r,
437 g_assert_cmpstr (pdf_dir, ==, pdf_dir_r);
440 guid_free (inv_acct);
441 guid_free (inv_acct_r);
442 guid_free (pmt_acct);
443 guid_free (pmt_acct_r);
448 void test_suite_engine_kvp_properties (
void)
450 GNC_TEST_ADD (suitename,
"Account",
Fixture, NULL, setup_account, test_account_kvp_properties, teardown);
451 GNC_TEST_ADD (suitename,
"Transaction",
Fixture, NULL, setup_trans, test_trans_kvp_properties, teardown);
452 GNC_TEST_ADD (suitename,
"Split",
Fixture, NULL, setup_split, test_split_kvp_properties, teardown);
453 GNC_TEST_ADD (suitename,
"Lot",
Fixture, NULL, setup_lot, test_lot_kvp_properties, teardown);
454 GNC_TEST_ADD (suitename,
"Customer",
Fixture, NULL, setup_customer, test_customer_kvp_properties, teardown);
455 GNC_TEST_ADD (suitename,
"Employee",
Fixture, NULL, setup_employee, test_employee_kvp_properties, teardown);
456 GNC_TEST_ADD (suitename,
"Job",
Fixture, NULL, setup_job, test_job_kvp_properties, teardown);
457 GNC_TEST_ADD (suitename,
"Vendor",
Fixture, NULL, setup_vendor, test_vendor_kvp_properties, teardown);
Transaction * xaccMallocTransaction(QofBook *book)
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
#define qof_instance_is_dirty
QofBook * qof_instance_get_book(gconstpointer)
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
QofBook * qof_book_new(void)
gboolean timespec_equal(const Timespec *ta, const Timespec *tb)
Use a 64-bit unsigned int timespec.
gboolean qof_begin_edit(QofInstance *inst)
GncGUID * guid_malloc(void)
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
void xaccTransBeginEdit(Transaction *trans)
Split * xaccMallocSplit(QofBook *book)
void xaccAccountBeginEdit(Account *acc)
Timespec timespec_now(void)
Account * xaccMallocAccount(QofBook *book)