Compare commits
No commits in common. "31a037460a9f89906bb13f8592bc50d4e874fad9" and "74719b762f32ec1c4c36e3718c81a42f265e3e7e" have entirely different histories.
31a037460a
...
74719b762f
17 changed files with 71 additions and 72 deletions
|
@ -10,7 +10,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_compile_options(/W4 /WX)
|
add_compile_options(/W4 /WX)
|
||||||
else()
|
else()
|
||||||
add_compile_options(-Wall -Wextra -pedantic -Woverloaded-virtual -Wredundant-decls -Wshadow)
|
add_compile_options(-Wall -Wpedantic)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "article.h"
|
#include "article.h"
|
||||||
|
|
||||||
//Article::Article() : Entity() {}
|
Article::Article() : Entity() {}
|
||||||
|
|
||||||
// Article::Article(std::shared_ptr<Seller> sellerPtr) : Entity() { sellerPtr_ = sellerPtr; }
|
// Article::Article(std::shared_ptr<Seller> sellerPtr) : Entity() { sellerPtr_ = sellerPtr; }
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ std::string Article::getDescription() { return description_; }
|
||||||
|
|
||||||
Seller* Article::getSeller() { return sellerPtr_; }
|
Seller* Article::getSeller() { return sellerPtr_; }
|
||||||
|
|
||||||
int Article::getPrice() const { return price_; }
|
int Article::getPrice() { return price_; }
|
||||||
|
|
||||||
int Article::getArticleNo() { return articleNo_; }
|
int Article::getArticleNo() {
|
||||||
|
return articleNo_;
|
||||||
|
}
|
|
@ -2,8 +2,8 @@
|
||||||
#define ARTICLE_H
|
#define ARTICLE_H
|
||||||
|
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
//#include "sale.h"
|
#include "sale.h"
|
||||||
//#include "seller.h"
|
#include "seller.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -14,20 +14,20 @@ class Sale;
|
||||||
class Article : public Entity
|
class Article : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Article() = default;
|
Article();
|
||||||
//virtual ~Article() = default;
|
//Article(std::shared_ptr<Seller> sellerPtr);
|
||||||
|
|
||||||
void setArticleNo(int articleNo);
|
void setArticleNo(int articleNo);
|
||||||
void setPrice(int price);
|
void setPrice(int price);
|
||||||
void setDescription(const std::string& description);
|
void setDescription(const std::string& description);
|
||||||
bool isSold();
|
bool isSold();
|
||||||
void setSale(Sale* salePtr);
|
void setSale(Sale* salePtr);
|
||||||
|
//void setSeller(std::shared_ptr<Seller> sellerPtr);
|
||||||
void setSeller(Seller* sellerPtr);
|
void setSeller(Seller* sellerPtr);
|
||||||
|
|
||||||
int getArticleNo();
|
int getArticleNo();
|
||||||
std::string getDescription();
|
std::string getDescription();
|
||||||
Seller* getSeller();
|
Seller* getSeller();
|
||||||
int getPrice() const;
|
int getPrice();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Seller* sellerPtr_{};
|
Seller* sellerPtr_{};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <boost/uuid/uuid_generators.hpp>
|
#include <boost/uuid/uuid_generators.hpp>
|
||||||
#include <boost/uuid/uuid_io.hpp>
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
|
|
||||||
Entity::~Entity() = default;
|
Entity::~Entity() {}
|
||||||
|
|
||||||
void Entity::createUuid()
|
void Entity::createUuid()
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ void Entity::setUuidFromString(const std::string& uuidString)
|
||||||
uuid_ = generator(uuidString);
|
uuid_ = generator(uuidString);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity::State Entity::getState() const
|
inline Entity::State Entity::getState() const
|
||||||
{
|
{
|
||||||
return state_;
|
return state_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ class Entity
|
||||||
public:
|
public:
|
||||||
enum class State { NEW, UPDATE, DELETE, OK };
|
enum class State { NEW, UPDATE, DELETE, OK };
|
||||||
|
|
||||||
//Entity() = default;
|
|
||||||
virtual ~Entity() = 0;
|
virtual ~Entity() = 0;
|
||||||
|
|
||||||
void createUuid();
|
void createUuid();
|
||||||
|
|
|
@ -22,13 +22,15 @@ void Marketplace::loadFromDb()
|
||||||
db.loadSellers(sellers_);
|
db.loadSellers(sellers_);
|
||||||
}
|
}
|
||||||
|
|
||||||
SellersVec& Marketplace::getSellers() { return sellers_; }
|
std::vector<std::unique_ptr<Seller>>& Marketplace::getSellers() { return sellers_; }
|
||||||
|
|
||||||
int Marketplace::getNextSellerNo()
|
int Marketplace::getNextSellerNo()
|
||||||
{
|
{
|
||||||
auto iter = std::max_element(
|
auto iter = std::max_element(
|
||||||
sellers_.begin(), sellers_.end(),
|
sellers_.begin(), sellers_.end(),
|
||||||
[](const auto& a, const auto& b) -> bool { return a->getSellerNo() < b->getSellerNo(); });
|
[](const std::unique_ptr<Seller>& a, const std::unique_ptr<Seller>& b) -> bool {
|
||||||
|
return a->getSellerNo() < b->getSellerNo();
|
||||||
|
});
|
||||||
if (iter == sellers_.end())
|
if (iter == sellers_.end())
|
||||||
return 1;
|
return 1;
|
||||||
return (*iter)->getSellerNo() + 1;
|
return (*iter)->getSellerNo() + 1;
|
||||||
|
@ -41,4 +43,7 @@ int Marketplace::getNumSellersDelete()
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Marketplace::sortSellers() { std::sort(sellers_.begin(), sellers_.end()); }
|
void Marketplace::sortSellers()
|
||||||
|
{
|
||||||
|
std::sort(sellers_.begin(), sellers_.end());
|
||||||
|
}
|
|
@ -7,29 +7,20 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
using SellersVec = std::vector<std::unique_ptr<Seller>>;
|
|
||||||
using SalesVec = std::vector<std::unique_ptr<Sale>>;
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
struct Basket {
|
|
||||||
};
|
|
||||||
|
|
||||||
class Marketplace
|
class Marketplace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Marketplace();
|
Marketplace();
|
||||||
void storeToDb(bool onlyDelete = false);
|
void storeToDb(bool onlyDelete = false);
|
||||||
void loadFromDb();
|
void loadFromDb();
|
||||||
SellersVec& getSellers();
|
std::vector<std::unique_ptr<Seller>>& getSellers();
|
||||||
int getNextSellerNo();
|
int getNextSellerNo();
|
||||||
int getNumSellersDelete();
|
int getNumSellersDelete();
|
||||||
void sortSellers();
|
void sortSellers();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SellersVec sellers_;
|
std::vector<std::unique_ptr<Seller>> sellers_;
|
||||||
SalesVec sales_;
|
std::vector<std::unique_ptr<Sale>> sales_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -2,20 +2,26 @@
|
||||||
|
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
void Sale::addArticle(Article* articlePtr)
|
void Sale::addArticle(std::shared_ptr<Article> articlePtr)
|
||||||
{
|
{
|
||||||
articlePtr->setSale(this);
|
articlePtr->setSale(this);
|
||||||
articles_.push_back(articlePtr);
|
articles_.push_back(articlePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Article*>& Sale::getArticles() { return articles_; }
|
std::vector<Article*> Sale::getArticles()
|
||||||
|
{
|
||||||
|
std::vector<Article*> articles(articles_.size());
|
||||||
|
for (const auto& article : articles_) {
|
||||||
|
articles.push_back(article.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return articles;
|
||||||
|
}
|
||||||
|
|
||||||
void Sale::removeArticle(const Article* articlePtr)
|
void Sale::removeArticle(const Article* articlePtr)
|
||||||
{
|
{
|
||||||
/* auto it = std::find_if(articles_.begin(), articles_.end(),
|
auto it = std::find_if(articles_.begin(), articles_.end(),
|
||||||
[&articlePtr](auto art) { return art.get() == articlePtr; }); */
|
[&articlePtr](auto art) { return art.get() == articlePtr; });
|
||||||
auto it = std::find(articles_.begin(), articles_.end(), articlePtr);
|
|
||||||
|
|
||||||
if (it != articles_.end()) {
|
if (it != articles_.end()) {
|
||||||
(*it)->setSale(nullptr);
|
(*it)->setSale(nullptr);
|
||||||
(*it)->setState(
|
(*it)->setState(
|
||||||
|
@ -27,7 +33,7 @@ void Sale::removeArticle(const Article* articlePtr)
|
||||||
int Sale::sumInCents()
|
int Sale::sumInCents()
|
||||||
{
|
{
|
||||||
int sum = std::accumulate(articles_.begin(), articles_.end(), 0,
|
int sum = std::accumulate(articles_.begin(), articles_.end(), 0,
|
||||||
[](int a, const Article* b) { return a + b->getPrice(); });
|
[](int a, std::shared_ptr<Article> b) { return a + b->getPrice(); });
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,15 @@
|
||||||
|
|
||||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||||
|
|
||||||
//class Article;
|
class Article;
|
||||||
|
|
||||||
using ArticlesVec = std::vector<Article*>;
|
|
||||||
|
|
||||||
class Sale : public Entity
|
class Sale : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void addArticle(Article* articlePtr);
|
void addArticle(std::shared_ptr<Article> articlePtr);
|
||||||
void setTimestamp(const std::string& timestamp);
|
void setTimestamp(const std::string& timestamp);
|
||||||
|
|
||||||
ArticlesVec& getArticles();
|
std::vector<Article*> getArticles();
|
||||||
std::string getTimestamp();
|
std::string getTimestamp();
|
||||||
int sumInCents();
|
int sumInCents();
|
||||||
|
|
||||||
|
@ -26,7 +24,7 @@ class Sale : public Entity
|
||||||
private:
|
private:
|
||||||
std::string timestamp_{
|
std::string timestamp_{
|
||||||
boost::posix_time::to_iso_extended_string(boost::posix_time::second_clock::local_time())};
|
boost::posix_time::to_iso_extended_string(boost::posix_time::second_clock::local_time())};
|
||||||
ArticlesVec articles_{};
|
std::vector<std::shared_ptr<Article>> articles_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,7 +1,10 @@
|
||||||
#include "seller.h"
|
#include "seller.h"
|
||||||
|
|
||||||
|
Seller::Seller() : Entity() {}
|
||||||
|
|
||||||
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
|
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
|
||||||
int numArticlesOffered) : Entity()
|
int numArticlesOffered)
|
||||||
|
: Entity()
|
||||||
{
|
{
|
||||||
firstName_ = firstName;
|
firstName_ = firstName;
|
||||||
lastName_ = lastName;
|
lastName_ = lastName;
|
||||||
|
@ -17,10 +20,10 @@ void Seller::setLastName(const std::string& lastName) { lastName_ = lastName; }
|
||||||
|
|
||||||
void Seller::setNumArticlesOffered(int number) { numArticlesOffered_ = number; }
|
void Seller::setNumArticlesOffered(int number) { numArticlesOffered_ = number; }
|
||||||
|
|
||||||
void Seller::addArticle(std::unique_ptr<Article> article)
|
void Seller::addArticle(std::shared_ptr<Article> article)
|
||||||
{
|
{
|
||||||
article->setSeller(this);
|
article->setSeller(this);
|
||||||
articles_.push_back(std::move(article));
|
articles_.push_back(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Seller::getFirstName() const { return firstName_; }
|
std::string Seller::getFirstName() const { return firstName_; }
|
||||||
|
@ -32,7 +35,7 @@ int Seller::getSellerNo() const { return sellerNo_; }
|
||||||
std::vector<Article*> Seller::getArticles(bool onlySold) const
|
std::vector<Article*> Seller::getArticles(bool onlySold) const
|
||||||
{
|
{
|
||||||
std::vector<Article*> articles;
|
std::vector<Article*> articles;
|
||||||
for (const auto& article : articles_) {
|
for (const auto article : articles_) {
|
||||||
if (onlySold && article->isSold()) {
|
if (onlySold && article->isSold()) {
|
||||||
articles.push_back(article.get());
|
articles.push_back(article.get());
|
||||||
} else if (!onlySold) {
|
} else if (!onlySold) {
|
||||||
|
@ -49,7 +52,7 @@ int Seller::numArticlesOffered() const { return numArticlesOffered_; }
|
||||||
void Seller::cleanupArticles()
|
void Seller::cleanupArticles()
|
||||||
{
|
{
|
||||||
articles_.erase(std::remove_if(articles_.begin(), articles_.end(),
|
articles_.erase(std::remove_if(articles_.begin(), articles_.end(),
|
||||||
[](const auto& article) {
|
[](const std::shared_ptr<Article>& article) {
|
||||||
return article->getState() == Article::State::DELETE;
|
return article->getState() == Article::State::DELETE;
|
||||||
}),
|
}),
|
||||||
articles_.end());
|
articles_.end());
|
||||||
|
|
|
@ -8,13 +8,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//class Article;
|
class Article;
|
||||||
|
|
||||||
class Seller : public Entity
|
class Seller : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Seller() = default;
|
Seller();
|
||||||
//virtual ~Seller() = default;
|
|
||||||
Seller(const std::string& firstName, const std::string& lastName, int sellerNo = 0,
|
Seller(const std::string& firstName, const std::string& lastName, int sellerNo = 0,
|
||||||
int numArticlesOffered = 0);
|
int numArticlesOffered = 0);
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ class Seller : public Entity
|
||||||
void setFirstName(const std::string& firstName);
|
void setFirstName(const std::string& firstName);
|
||||||
void setLastName(const std::string& lastName);
|
void setLastName(const std::string& lastName);
|
||||||
void setNumArticlesOffered(int number);
|
void setNumArticlesOffered(int number);
|
||||||
void addArticle(std::unique_ptr<Article> article);
|
void addArticle(std::shared_ptr<Article> article);
|
||||||
void cleanupArticles();
|
void cleanupArticles();
|
||||||
|
|
||||||
std::string getFirstName() const;
|
std::string getFirstName() const;
|
||||||
|
@ -41,7 +40,7 @@ class Seller : public Entity
|
||||||
int numArticlesOffered_{};
|
int numArticlesOffered_{};
|
||||||
std::string firstName_{};
|
std::string firstName_{};
|
||||||
std::string lastName_{};
|
std::string lastName_{};
|
||||||
std::vector<std::unique_ptr<Article>> articles_{};
|
std::vector<std::shared_ptr<Article>> articles_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -9,12 +9,12 @@ SellerModel::SellerModel(Marketplace* market, QObject* parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int SellerModel::rowCount([[maybe_unused]] const QModelIndex& parent) const
|
int SellerModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
return marketplace_->getSellers().size();
|
return marketplace_->getSellers().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SellerModel::columnCount([[maybe_unused]] const QModelIndex& parent) const { return 5; }
|
int SellerModel::columnCount(const QModelIndex& parent) const { return 5; }
|
||||||
|
|
||||||
QVariant SellerModel::data(const QModelIndex& index, int role) const
|
QVariant SellerModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
|
@ -92,8 +92,8 @@ bool SellerModel::setData(const QModelIndex& index, const QVariant& value, int r
|
||||||
return false;
|
return false;
|
||||||
auto iter =
|
auto iter =
|
||||||
std::find_if(marketplace_->getSellers().begin(), marketplace_->getSellers().end(),
|
std::find_if(marketplace_->getSellers().begin(), marketplace_->getSellers().end(),
|
||||||
[&value](const std::unique_ptr<Seller>& s) {
|
[&value](const std::unique_ptr<Seller>& seller) {
|
||||||
return value.toInt() == s->getSellerNo();
|
return value.toInt() == seller->getSellerNo();
|
||||||
});
|
});
|
||||||
if (iter != marketplace_->getSellers().end()) {
|
if (iter != marketplace_->getSellers().end()) {
|
||||||
emit duplicateSellerNo(
|
emit duplicateSellerNo(
|
||||||
|
|
|
@ -16,7 +16,7 @@ class SellerModel : public QAbstractTableModel
|
||||||
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
|
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||||
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||||
virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
||||||
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#define BOOST_TEST_MODULE article
|
#define BOOST_TEST_MODULE article
|
||||||
|
|
||||||
#include "../src/core/article.h"
|
#include "../src/core/article.h"
|
||||||
#include "../src/core/sale.h"
|
|
||||||
|
|
||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@ BOOST_AUTO_TEST_CASE(check_is_sold)
|
||||||
Article article{};
|
Article article{};
|
||||||
BOOST_TEST(article.isSold() == false);
|
BOOST_TEST(article.isSold() == false);
|
||||||
|
|
||||||
auto salePtr = std::make_unique<Sale>();
|
auto salePtr = std::make_shared<Sale>();
|
||||||
salePtr->addArticle(&article);
|
article.setSale(salePtr.get());
|
||||||
BOOST_TEST(article.isSold() == true);
|
BOOST_TEST(article.isSold() == true);
|
||||||
}
|
}
|
|
@ -30,11 +30,11 @@ BOOST_AUTO_TEST_CASE(store_sellers_succ)
|
||||||
auto b = std::make_unique<Seller>("Max", "Mustermann");
|
auto b = std::make_unique<Seller>("Max", "Mustermann");
|
||||||
b->createUuid();
|
b->createUuid();
|
||||||
b->setSellerNo(2);
|
b->setSellerNo(2);
|
||||||
auto c = std::make_unique<Article>();
|
auto c = std::make_shared<Article>();
|
||||||
c->createUuid();
|
c->createUuid();
|
||||||
c->setPrice(500);
|
c->setPrice(500);
|
||||||
c->setDescription("Test");
|
c->setDescription("Test");
|
||||||
b->addArticle(std::move(c));
|
b->addArticle(c);
|
||||||
BOOST_TEST(a->getUuid() != b->getUuid());
|
BOOST_TEST(a->getUuid() != b->getUuid());
|
||||||
sellers.push_back(std::move(a));
|
sellers.push_back(std::move(a));
|
||||||
sellers.push_back(std::move(b));
|
sellers.push_back(std::move(b));
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#define BOOST_TEST_MODULE sale
|
#define BOOST_TEST_MODULE sale
|
||||||
|
|
||||||
#include "../src/core/sale.h"
|
#include "../src/core/sale.h"
|
||||||
#include "../src/core/seller.h"
|
|
||||||
#include "../src/core/article.h"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -14,15 +12,15 @@ BOOST_AUTO_TEST_CASE(articles_sum)
|
||||||
const int NUM_ARTICLES = 30;
|
const int NUM_ARTICLES = 30;
|
||||||
|
|
||||||
Seller seller("Max", "Mustermann", 1, NUM_ARTICLES);
|
Seller seller("Max", "Mustermann", 1, NUM_ARTICLES);
|
||||||
ArticlesVec articles{};
|
std::vector<std::shared_ptr<Article>> articles{};
|
||||||
Sale sale{};
|
Sale sale{};
|
||||||
|
|
||||||
for(int i = 0; i < NUM_ARTICLES; ++i)
|
for(int i = 0; i < NUM_ARTICLES; ++i)
|
||||||
{
|
{
|
||||||
auto art = std::make_unique<Article>();
|
auto art = std::make_shared<Article>();
|
||||||
art->setPrice((i+1) * 10);
|
art->setPrice((i+1) * 10);
|
||||||
articles.push_back(art.get());
|
articles.push_back(art);
|
||||||
seller.addArticle(std::move(art));
|
seller.addArticle(art);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 10; ++i)
|
for(int i = 0; i < 10; ++i)
|
||||||
|
@ -39,7 +37,7 @@ BOOST_AUTO_TEST_CASE(remove_article) {
|
||||||
Sale sale{};
|
Sale sale{};
|
||||||
|
|
||||||
BOOST_TEST(art->isSold() == false);
|
BOOST_TEST(art->isSold() == false);
|
||||||
sale.addArticle(art.get());
|
sale.addArticle(art);
|
||||||
BOOST_TEST(art->isSold() == true);
|
BOOST_TEST(art->isSold() == true);
|
||||||
sale.removeArticle(art.get());
|
sale.removeArticle(art.get());
|
||||||
BOOST_TEST(art->isSold() == false);
|
BOOST_TEST(art->isSold() == false);
|
||||||
|
|
|
@ -30,11 +30,10 @@ BOOST_AUTO_TEST_CASE(create_many)
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(with_article) {
|
BOOST_AUTO_TEST_CASE(with_article) {
|
||||||
Seller seller{"Max", "Mustermann"};
|
Seller seller("Max", "Mustermann");
|
||||||
auto article = std::make_unique<Article>();
|
auto article = std::make_shared<Article>();
|
||||||
article->setDescription("Test article");
|
article->setDescription("Test article");
|
||||||
seller.addArticle(std::move(article));
|
seller.addArticle(article);
|
||||||
BOOST_TEST((article == nullptr));
|
|
||||||
BOOST_TEST(seller.getArticles(false).at(0)->getDescription() == "Test article");
|
BOOST_TEST(seller.getArticles(false).at(0)->getDescription() == "Test article");
|
||||||
BOOST_TEST(seller.numArticlesSold() == 0);
|
BOOST_TEST(seller.numArticlesSold() == 0);
|
||||||
}
|
}
|
Loading…
Reference in a new issue