10Duke Scale C++ Client
Loading...
Searching...
No Matches
JSONObjectMock.h
1#ifndef TENDUKE_TEST_MOCKS_JSONOBJECTMOCK_H
2#define TENDUKE_TEST_MOCKS_JSONOBJECTMOCK_H
3
4#include "json/JSONObject.h"
5#include "gmock/gmock.h"
6
7namespace tenduke { namespace test { namespace mocks {
8
10{
11 // tenduke::json::JSONElement interface
12public:
13 MOCK_METHOD(enum Type, getType, (), (const, override));
14 MOCK_METHOD(std::string, asString, (), (const, override));
15
16public:
17 MOCK_METHOD(std::shared_ptr<tenduke::json::JSONElement>, getProperty, (const std::string &a), (const, override));
18 MOCK_METHOD(bool, hasProperty, (const std::string &a), (const, override));
19 MOCK_METHOD(std::shared_ptr<tenduke::json::JSONElement>, removeProperty, (const std::string &a), (override));
20
21 MOCK_METHOD((const std::map<std::string, std::shared_ptr<tenduke::json::JSONElement>> &), getProperties, (), (const, override));
22
23 std::map<std::string, std::shared_ptr<tenduke::json::JSONElement>> properties;
24
25 static JSONObjectMock * create()
26 {
27 auto mock = new JSONObjectMock();
28 EXPECT_CALL(*mock, getType()).WillRepeatedly(::testing::Return(tenduke::json::JSONElement::Type::OBJECT));
29
30 return mock;
31 }
32 static std::unique_ptr<JSONObjectMock> createUnique()
33 {
34 return std::unique_ptr<JSONObjectMock>(create());
35 }
36 static std::shared_ptr<JSONObjectMock> createShared()
37 {
38 return std::shared_ptr<JSONObjectMock>(create());
39 }
40
41};
42
43}}}
44
45#endif //TENDUKE_TEST_MOCKS_JSONOBJECTMOCK_H
virtual enum Type getType() const =0
Returns type of this element.
virtual std::string asString() const =0
Returns string representation of this element.
Type
Type of the element.
Definition JSONElement.h:17
JSON object element.
Definition JSONObject.h:16
virtual std::shared_ptr< JSONElement > removeProperty(const std::string &propertyName)=0
Removes property from this object.
virtual const std::map< std::string, std::shared_ptr< JSONElement > > & getProperties() const =0
Returns all properties of this object.
virtual bool hasProperty(const std::string &propertyName) const =0
Checks if the object has a property with given name.
virtual std::shared_ptr< JSONElement > getProperty(const std::string &propertyName) const =0
Returns object property by name.
Definition JSONObjectMock.h:10
Root for classes, functions and globals of 10Duke C++ Client.
Definition BackendConfiguration.h:7