Since GoogleMock is part of GoogleTest, we will present them together:
#include "merchants/reviews.h"
#include <gmock/gmock.h>
#include <merchants/visited_merchant_history.h>
#include "fake_customer_review_store.h"
namespace {
class mock_visited_merchant : public i_visited_merchant {
public:
explicit mock_visited_merchant(fake_customer_review_store &store,
merchant_id_t id)
: review_store_{store},
review_{store.get_review_for_merchant(id).value()} {
ON_CALL(*this, post_rating).WillByDefault([this](stars s) {
review_.rating = s;
review_store_.post_review(review_);
});
ON_CALL(*this, get_rating).WillByDefault([this] { return review_.rating; });
}
MOCK_METHOD(stars, get_rating, (), (override));
MOCK_METHOD(void, post_rating, (stars s), (override));
private:
fake_customer_review_store &review_store_;
review review_;
};
} // namespace
class history_with_one_rated_merchant...