RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
mockRepositoryIf.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_COMPONENTFRAMEWORK_TEST_MOCKREPOSITORYIF_HPP
14#define RTCTK_COMPONENTFRAMEWORK_TEST_MOCKREPOSITORYIF_HPP
15
17
19
25class MockRepositoryIf : virtual public RepositoryIf {
26public:
28 // Setup the default behaviour to forward the calls to the fake repository.
29 ON_CALL(*this, CreateDataPoint)
30 .WillByDefault([this](const DataPointPath& path, const std::type_info& type) {
31 m_fakerepo.CreateDataPoint(path, type);
32 });
33 ON_CALL(*this, DeleteDataPoint).WillByDefault([this](const DataPointPath& path) {
34 m_fakerepo.DeleteDataPoint(path);
35 });
36 ON_CALL(*this, GetDataPointType)
37 .WillByDefault([this](const DataPointPath& path) -> const std::type_info& {
38 return m_fakerepo.GetDataPointType(path);
39 });
40 ON_CALL(*this, GetDataPointSize).WillByDefault([this](const DataPointPath& path) {
41 return m_fakerepo.GetDataPointSize(path);
42 });
43 ON_CALL(*this, DataPointExists).WillByDefault([this](const DataPointPath& path) {
44 return m_fakerepo.DataPointExists(path);
45 });
46 ON_CALL(*this, GetChildren).WillByDefault([this](const DataPointPath& path) {
47 return m_fakerepo.GetChildren(path);
48 });
49 ON_CALL(*this, SendReadRequest).WillByDefault([this](const ReadRequest& request) {
50 return m_fakerepo.SendReadRequest(request);
51 });
52 ON_CALL(*this, SendWriteRequest).WillByDefault([this](const WriteRequest& request) {
53 return m_fakerepo.SendWriteRequest(request);
54 });
55 }
56
58 MOCK_METHOD(void, CreateDataPoint, (const DataPointPath&, const std::type_info&), (override));
59 MOCK_METHOD(void, DeleteDataPoint, (const DataPointPath&), (override));
60 MOCK_METHOD(const std::type_info&, GetDataPointType, (const DataPointPath&), (const override));
61 MOCK_METHOD(std::size_t, GetDataPointSize, (const DataPointPath&), (const override));
62 MOCK_METHOD(bool, DataPointExists, (const DataPointPath&), (const override));
63 MOCK_METHOD((std::pair<PathList, PathList>),
65 (const DataPointPath&),
66 (const override));
67 MOCK_METHOD(Response, SendReadRequest, (const ReadRequest&), (const override));
69
70private:
71 FakeRepositoryIf m_fakerepo;
72};
73
74} // namespace rtctk::componentFramework::test
75
76#endif // RTCTK_COMPONENTFRAMEWORK_TEST_MOCKREPOSITORYIF_HPP
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
A request object to pass information about datapoints that should be read from the repository.
Definition: repositoryIf.hpp:49
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:197
A request object to pass information about datapoints that should be written to the repository.
Definition: repositoryIf.hpp:122
Abstract interface providing basic read and write facilities to a repository.
Definition: repositoryIf.hpp:38
virtual const std::type_info & GetDataPointType(const DataPointPath &path) const =0
Fetches the type of the datapoint.
virtual size_t GetDataPointSize(const DataPointPath &path) const =0
Fetches the size of the datapoint's data.
virtual std::pair< PathList, PathList > GetChildren(const DataPointPath &path) const =0
Queries the datapoints and child paths for a given path.
virtual void CreateDataPoint(const DataPointPath &path, const std::type_info &type)=0
Creates a new datapoint in the repository with a specified type.
virtual void DeleteDataPoint(const DataPointPath &path)=0
Deletes a datapoint.
virtual bool DataPointExists(const DataPointPath &path) const =0
Checks for the existence of a datapoint in the repository.
virtual Response SendWriteRequest(const WriteRequest &request)=0
Sends a request to write data to the repository.
virtual Response SendReadRequest(const ReadRequest &request) const =0
Sends a request to read data from the repository.
Implementation of an in-memory fake repository for testing.
Definition: fakeRepositoryIf.hpp:31
Response SendReadRequest(const ReadRequest &) const override
Sends a request to read data from the repository.
Definition: fakeRepositoryIf.cpp:99
const std::type_info & GetDataPointType(const DataPointPath &) const override
Fetches the type of the datapoint.
Definition: fakeRepositoryIf.cpp:41
Response SendWriteRequest(const WriteRequest &) override
Sends a request to write data to the repository.
Definition: fakeRepositoryIf.cpp:103
std::size_t GetDataPointSize(const DataPointPath &) const override
Fetches the size of the datapoint's data.
Definition: fakeRepositoryIf.cpp:50
bool DataPointExists(const DataPointPath &) const override
Checks for the existence of a datapoint in the repository.
Definition: fakeRepositoryIf.cpp:60
void DeleteDataPoint(const DataPointPath &) override
Deletes a datapoint.
Definition: fakeRepositoryIf.cpp:28
void CreateDataPoint(const DataPointPath &, const std::type_info &) override
Creates a new datapoint in the repository with a specified type.
Definition: fakeRepositoryIf.cpp:19
std::pair< PathList, PathList > GetChildren(const DataPointPath &) const override
Queries the datapoints and child paths for a given path.
Definition: fakeRepositoryIf.cpp:66
A mock of RepositoryIf.
Definition: mockRepositoryIf.hpp:25
MOCK_METHOD(void, DeleteDataPoint,(const DataPointPath &),(override))
MockRepositoryIf()
Definition: mockRepositoryIf.hpp:27
MOCK_METHOD(Response, SendReadRequest,(const ReadRequest &),(const override))
virtual void CreateDataPoint(const DataPointPath &path, const std::type_info &type)=0
Creates a new datapoint in the repository with a specified type.
MOCK_METHOD((std::pair< PathList, PathList >), GetChildren,(const DataPointPath &),(const override))
MOCK_METHOD(Response, SendWriteRequest,(const WriteRequest &),(override))
MOCK_METHOD(void, CreateDataPoint,(const DataPointPath &, const std::type_info &),(override))
MOCK_METHOD(bool, DataPointExists,(const DataPointPath &),(const override))
MOCK_METHOD(const std::type_info &, GetDataPointType,(const DataPointPath &),(const override))
MOCK_METHOD(std::size_t, GetDataPointSize,(const DataPointPath &),(const override))
Header file for an in-memory fake RepositoryIf.
Definition: fakeClock.cpp:15