more test cases
This commit is contained in:
parent
f42855dc50
commit
ddfb9471a8
1 changed files with 42 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
#define BOOST_TEST_MODULE database
|
#define BOOST_TEST_MODULE database
|
||||||
|
|
||||||
#include "../src/core/database.h"
|
#include "../src/core/database.h"
|
||||||
|
#include "../src/core/seller.h"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
@ -11,5 +12,46 @@ BOOST_AUTO_TEST_CASE(create_database)
|
||||||
|
|
||||||
Database db(":memory:");
|
Database db(":memory:");
|
||||||
BOOST_CHECK_NO_THROW(db.init());
|
BOOST_CHECK_NO_THROW(db.init());
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(store_seller_fail)
|
||||||
|
{
|
||||||
|
Database db(":memory:");
|
||||||
|
db.init();
|
||||||
|
std::vector<Seller> sellers;
|
||||||
|
sellers.push_back({});
|
||||||
|
sellers.push_back({});
|
||||||
|
BOOST_CHECK_THROW(db.storeSellers(sellers), std::runtime_error);
|
||||||
|
}
|
||||||
|
BOOST_AUTO_TEST_CASE(store_sellers_succ)
|
||||||
|
{
|
||||||
|
Database db(":memory:");
|
||||||
|
db.init();
|
||||||
|
std::vector<Seller> sellers;
|
||||||
|
Seller a{};
|
||||||
|
a.createUuid();
|
||||||
|
a.setSellerNo(1);
|
||||||
|
Seller b{};
|
||||||
|
b.createUuid();
|
||||||
|
b.setSellerNo(2);
|
||||||
|
BOOST_TEST(a.getUuid() != b.getUuid());
|
||||||
|
sellers.push_back(a);
|
||||||
|
sellers.push_back(b);
|
||||||
|
BOOST_CHECK_NO_THROW(db.storeSellers(sellers));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(seller_states)
|
||||||
|
{
|
||||||
|
Database db(":memory:");
|
||||||
|
db.init();
|
||||||
|
std::vector<Seller> sellers;
|
||||||
|
Seller a;
|
||||||
|
a.setSellerNo(3);
|
||||||
|
a.createUuid();
|
||||||
|
sellers.push_back(a);
|
||||||
|
std::cout << "Anzahl sellers: " << sellers.size() << "\n";
|
||||||
|
BOOST_TEST((sellers.at(0).getState() == Entity::State::NEW));
|
||||||
|
BOOST_TEST(db.storeSellers(sellers) == 1);
|
||||||
|
BOOST_TEST((sellers.at(0).getState() == Entity::State::CLEAN));
|
||||||
|
BOOST_TEST(db.storeSellers(sellers) == 0);
|
||||||
}
|
}
|
Loading…
Reference in a new issue