summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/administration_rw_tests.cpp1
-rw-r--r--tests/administration_validation_tests.cpp43
-rw-r--r--tests/peppol_write_tests.cpp37
3 files changed, 41 insertions, 40 deletions
diff --git a/tests/administration_rw_tests.cpp b/tests/administration_rw_tests.cpp
index aed3c52..ba5507e 100644
--- a/tests/administration_rw_tests.cpp
+++ b/tests/administration_rw_tests.cpp
@@ -135,6 +135,7 @@ TEST _administration_rw_contact(void)
strops_copy(pw.address.country_code, "FR", sizeof(pw.address.country_code));
strops_copy(pw.address.city, "Paris", sizeof(pw.address.city));
strops_copy(pw.address.postal, "12345", sizeof(pw.address.postal));
+ strops_copy(pw.email, "test@test.com", sizeof(pw.email));
pw.type = contact_type::CONTACT_CONSUMER;
count = administration_contact_count();
diff --git a/tests/administration_validation_tests.cpp b/tests/administration_validation_tests.cpp
index 4b88e37..f307d2d 100644
--- a/tests/administration_validation_tests.cpp
+++ b/tests/administration_validation_tests.cpp
@@ -208,16 +208,23 @@ TEST _administration_validate_costcenter_isvalid(void)
// Contact
//////////////////
-TEST _administration_validate_contact_add(void)
+contact _create_test_contact()
{
- administration_create_empty("");
contact p1 = administration_contact_create_empty();
strops_copy(p1.name, "John Johnsson", sizeof(p1.name));
strops_copy(p1.address.address1, "Address 1", sizeof(p1.address.address1));
strops_copy(p1.address.country_code, "FR", sizeof(p1.address.country_code));
strops_copy(p1.address.city, "Paris", sizeof(p1.address.city));
strops_copy(p1.address.postal, "12345", sizeof(p1.address.postal));
+ strops_copy(p1.email, "test@test.com", sizeof(p1.email));
p1.type = contact_type::CONTACT_CONSUMER;
+ return p1;
+}
+
+TEST _administration_validate_contact_add(void)
+{
+ administration_create_empty("");
+ contact p1 = _create_test_contact();
ASSERT_EQ(administration_contact_add(p1), A_ERR_SUCCESS);
@@ -243,13 +250,7 @@ TEST _administration_validate_contact_import(void)
{
administration_create_empty("");
- contact p1 = administration_contact_create_empty();
- strops_copy(p1.name, "John Johnsson", sizeof(p1.name));
- strops_copy(p1.address.address1, "Address 1", sizeof(p1.address.address1));
- strops_copy(p1.address.country_code, "FR", sizeof(p1.address.country_code));
- strops_copy(p1.address.city, "Paris", sizeof(p1.address.city));
- strops_copy(p1.address.postal, "12345", sizeof(p1.address.postal));
- p1.type = contact_type::CONTACT_CONSUMER;
+ contact p1 = _create_test_contact();
ASSERT_EQ(administration_contact_import(p1), A_ERR_SUCCESS);
@@ -275,13 +276,7 @@ TEST _administration_validate_contact_import(void)
TEST _administration_validate_contact_update(void)
{
administration_create_empty("");
- contact p1 = administration_contact_create_empty();
- strops_copy(p1.name, "John Johnsson", sizeof(p1.name));
- strops_copy(p1.address.address1, "Address 1", sizeof(p1.address.address1));
- strops_copy(p1.address.country_code, "FR", sizeof(p1.address.country_code));
- strops_copy(p1.address.city, "Paris", sizeof(p1.address.city));
- strops_copy(p1.address.postal, "12345", sizeof(p1.address.postal));
- p1.type = contact_type::CONTACT_CONSUMER;
+ contact p1 = _create_test_contact();
ASSERT_EQ(administration_contact_add(p1), A_ERR_SUCCESS);
ASSERT_EQ(administration_contact_update(p1), A_ERR_SUCCESS);
@@ -316,13 +311,7 @@ TEST _administration_validate_contact_update(void)
TEST _administration_validate_contact_remove(void)
{
administration_create_empty("");
- contact p1 = administration_contact_create_empty();
- strops_copy(p1.name, "John Johnsson", sizeof(p1.name));
- strops_copy(p1.address.address1, "Address 1", sizeof(p1.address.address1));
- strops_copy(p1.address.country_code, "FR", sizeof(p1.address.country_code));
- strops_copy(p1.address.city, "Paris", sizeof(p1.address.city));
- strops_copy(p1.address.postal, "12345", sizeof(p1.address.postal));
- p1.type = contact_type::CONTACT_CONSUMER;
+ contact p1 = _create_test_contact();
ASSERT_EQ(administration_contact_add(p1), A_ERR_SUCCESS);
@@ -338,13 +327,7 @@ TEST _administration_validate_contact_remove(void)
TEST _administration_validate_contact_isvalid(void)
{
administration_create_empty("");
- contact p1 = administration_contact_create_empty();
- strops_copy(p1.name, "John Johnsson", sizeof(p1.name));
- strops_copy(p1.address.address1, "Address 1", sizeof(p1.address.address1));
- strops_copy(p1.address.country_code, "FR", sizeof(p1.address.country_code));
- strops_copy(p1.address.city, "Paris", sizeof(p1.address.city));
- strops_copy(p1.address.postal, "12345", sizeof(p1.address.postal));
- p1.type = contact_type::CONTACT_CONSUMER;
+ contact p1 = _create_test_contact();
ASSERT_EQ(administration_contact_is_valid(p1), A_ERR_SUCCESS);
ASSERT_EQ(administration_contact_is_valid(p1), A_ERR_SUCCESS);
diff --git a/tests/peppol_write_tests.cpp b/tests/peppol_write_tests.cpp
index e77f128..c00b53b 100644
--- a/tests/peppol_write_tests.cpp
+++ b/tests/peppol_write_tests.cpp
@@ -10,25 +10,21 @@ char* extract_dir = "build\\extracted";
static contact _create_nl_business()
{
contact pw = administration_contact_create_empty();
- strops_copy(pw.name, "John Johnsson", sizeof(pw.name));
+ strops_copy(pw.name, "Piet Pinda", sizeof(pw.name));
strops_copy(pw.address.address1, "Address 1", sizeof(pw.address.address1));
strops_copy(pw.address.country_code, "NL", sizeof(pw.address.country_code));
strops_copy(pw.address.city, "Amsterdam", sizeof(pw.address.city));
strops_copy(pw.address.postal, "1234AA", sizeof(pw.address.postal));
strops_copy(pw.taxid, "T123", sizeof(pw.taxid));
strops_copy(pw.businessid, "B321", sizeof(pw.businessid));
+ strops_copy(pw.email, "test@test.com", sizeof(pw.email));
pw.type = contact_type::CONTACT_BUSINESS;
return pw;
}
static contact _create_nl_consumer()
{
- contact pw = administration_contact_create_empty();
- strops_copy(pw.name, "Hans Klok", sizeof(pw.name));
- strops_copy(pw.address.address1, "Address 2", sizeof(pw.address.address1));
- strops_copy(pw.address.country_code, "NL", sizeof(pw.address.country_code));
- strops_copy(pw.address.city, "Amsterdam", sizeof(pw.address.city));
- strops_copy(pw.address.postal, "4321AA", sizeof(pw.address.postal));
+ contact pw = _create_nl_business();
pw.type = contact_type::CONTACT_CONSUMER;
return pw;
}
@@ -44,9 +40,28 @@ static billing_item _create_bi1(invoice *inv)
item.discount_is_percentage = 0;
tax_rate buffer[20];
- char* country_codes[2] = {inv->supplier.address.country_code, inv->customer.address.country_code};
- administration_tax_rate_get_by_country(buffer, 2, country_codes);
- tax_rate rand_rate = buffer[0];
+ char* _country_codes[2] = {inv->supplier.address.country_code, inv->customer.address.country_code};
+ u32 tax_rate_count = administration_tax_rate_get_by_country(buffer, 2, _country_codes);
+ tax_rate rand_rate = buffer[tax_rate_count-1];
+ strops_copy(item.tax_rate_id, rand_rate.id, MAX_LEN_ID);
+
+ return item;
+}
+
+static billing_item _create_bi2(invoice *inv)
+{
+ billing_item item = administration_billing_item_create_empty();
+ item.amount = 2;
+ item.amount_is_percentage = 0;
+ strops_copy(item.description, "Soap", MAX_LEN_LONG_DESC);
+ item.net_per_item = 5.00f;
+ item.discount = 5.0f;
+ item.discount_is_percentage = 1;
+
+ tax_rate buffer[20];
+ char* _country_codes[2] = {inv->supplier.address.country_code, inv->customer.address.country_code};
+ u32 tax_rate_count = administration_tax_rate_get_by_country(buffer, 2, _country_codes);
+ tax_rate rand_rate = buffer[tax_rate_count-1];
strops_copy(item.tax_rate_id, rand_rate.id, MAX_LEN_ID);
return item;
@@ -125,6 +140,7 @@ TEST _peppol_write_nl2nl_b2b(void)
inv.expires_at = inv.issued_at + 1000;
administration_billing_item_add_to_invoice(&inv, _create_bi1(&inv));
+ administration_billing_item_add_to_invoice(&inv, _create_bi2(&inv));
ASSERT_EQ(administration_invoice_add(&inv), A_ERR_SUCCESS);
if (_test_peppol_file(inv.id)) { PASS(); } else { FAIL(); }
@@ -145,6 +161,7 @@ TEST _peppol_write_nl2nl_b2c(void)
inv.expires_at = inv.issued_at + 1000;
administration_billing_item_add_to_invoice(&inv, _create_bi1(&inv));
+ administration_billing_item_add_to_invoice(&inv, _create_bi2(&inv));
ASSERT_EQ(administration_invoice_add(&inv), A_ERR_SUCCESS);
if (_test_peppol_file(inv.id)) { PASS(); } else { FAIL(); }