refacturing
This commit is contained in:
parent
051ed3e730
commit
2fb72f1701
6 changed files with 60 additions and 15 deletions
33
test/test_sale.cpp
Normal file
33
test/test_sale.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#define BOOST_TEST_MODULE sale
|
||||
|
||||
#include "../src/core/sale.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(articles_sum)
|
||||
{
|
||||
const int NUM_ARTICLES = 30;
|
||||
|
||||
Seller seller("Max", "Mustermann", 1, NUM_ARTICLES);
|
||||
std::vector<std::shared_ptr<Article>> articles{};
|
||||
Sale sale{};
|
||||
|
||||
for(int i = 0; i < NUM_ARTICLES; ++i)
|
||||
{
|
||||
auto art = std::make_shared<Article>();
|
||||
art->setPrice((i+1) * 10);
|
||||
articles.push_back(art);
|
||||
seller.addArticle(art);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 10; ++i)
|
||||
{
|
||||
sale.addArticle(articles.at(i));
|
||||
}
|
||||
|
||||
BOOST_TEST(sale.sumInCents() == 550);
|
||||
BOOST_TEST(seller.getArticles(true).size() == 10);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue