test cases adopted
This commit is contained in:
parent
d321a5d95e
commit
3be2418102
1 changed files with 22 additions and 17 deletions
|
@ -17,23 +17,28 @@ BOOST_AUTO_TEST_CASE(store_seller_fail)
|
||||||
{
|
{
|
||||||
Database db(":memory:");
|
Database db(":memory:");
|
||||||
db.init();
|
db.init();
|
||||||
std::vector<Seller> sellers;
|
std::vector<std::shared_ptr<Seller>> sellers;
|
||||||
sellers.push_back({});
|
sellers.push_back(std::make_shared<Seller>());
|
||||||
sellers.push_back({});
|
sellers.push_back(std::make_shared<Seller>());
|
||||||
BOOST_CHECK_THROW(db.storeSellers(sellers), std::runtime_error);
|
BOOST_CHECK_THROW(db.storeSellers(sellers), std::runtime_error);
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_CASE(store_sellers_succ)
|
BOOST_AUTO_TEST_CASE(store_sellers_succ)
|
||||||
{
|
{
|
||||||
Database db(":memory:");
|
Database db(":memory:");
|
||||||
db.init();
|
db.init();
|
||||||
std::vector<Seller> sellers;
|
std::vector<std::shared_ptr<Seller>> sellers;
|
||||||
Seller a{};
|
auto a = std::make_shared<Seller>();
|
||||||
a.createUuid();
|
a->createUuid();
|
||||||
a.setSellerNo(1);
|
a->setSellerNo(1);
|
||||||
Seller b{};
|
auto b = std::make_shared<Seller>("Max", "Mustermann");
|
||||||
b.createUuid();
|
b->createUuid();
|
||||||
b.setSellerNo(2);
|
b->setSellerNo(2);
|
||||||
BOOST_TEST(a.getUuid() != b.getUuid());
|
auto c = std::make_shared<Article>();
|
||||||
|
c->createUuid();
|
||||||
|
c->setPrice(500);
|
||||||
|
c->setDescription("Test");
|
||||||
|
b->addArticle(c);
|
||||||
|
BOOST_TEST(a->getUuid() != b->getUuid());
|
||||||
sellers.push_back(a);
|
sellers.push_back(a);
|
||||||
sellers.push_back(b);
|
sellers.push_back(b);
|
||||||
BOOST_CHECK_NO_THROW(db.storeSellers(sellers));
|
BOOST_CHECK_NO_THROW(db.storeSellers(sellers));
|
||||||
|
@ -43,14 +48,14 @@ BOOST_AUTO_TEST_CASE(seller_states)
|
||||||
{
|
{
|
||||||
Database db(":memory:");
|
Database db(":memory:");
|
||||||
db.init();
|
db.init();
|
||||||
std::vector<Seller> sellers;
|
std::vector<std::shared_ptr<Seller>> sellers;
|
||||||
Seller a;
|
auto a = std::make_shared<Seller>();
|
||||||
a.setSellerNo(3);
|
a->setSellerNo(3);
|
||||||
a.createUuid();
|
a->createUuid();
|
||||||
sellers.push_back(a);
|
sellers.push_back(a);
|
||||||
std::cout << "Anzahl sellers: " << sellers.size() << "\n";
|
std::cout << "Anzahl sellers: " << sellers.size() << "\n";
|
||||||
BOOST_TEST((sellers.at(0).getState() == Entity::State::NEW));
|
BOOST_TEST((sellers.at(0)->getState() == Entity::State::NEW));
|
||||||
BOOST_TEST(db.storeSellers(sellers) == 1);
|
BOOST_TEST(db.storeSellers(sellers) == 1);
|
||||||
BOOST_TEST((sellers.at(0).getState() == Entity::State::OK));
|
BOOST_TEST((sellers.at(0)->getState() == Entity::State::OK));
|
||||||
BOOST_TEST(db.storeSellers(sellers) == 0);
|
BOOST_TEST(db.storeSellers(sellers) == 0);
|
||||||
}
|
}
|
Loading…
Reference in a new issue