Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "binarystore.hpp" |
| 4 | |
| 5 | #include <gmock/gmock.h> |
| 6 | |
Kun Yi | 64dc05c | 2018-12-19 13:19:03 -0800 | [diff] [blame] | 7 | using ::testing::Invoke; |
| 8 | |
Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 9 | namespace binstore |
| 10 | { |
| 11 | |
| 12 | class MockBinaryStore : public BinaryStoreInterface |
| 13 | { |
| 14 | public: |
Kun Yi | 64dc05c | 2018-12-19 13:19:03 -0800 | [diff] [blame] | 15 | MockBinaryStore(const std::string& baseBlobId, int fd, uint32_t offset, |
| 16 | uint32_t maxSize) : |
| 17 | real_store_(baseBlobId, fd, offset, maxSize) |
| 18 | { |
| 19 | // Implemented calls in BinaryStore will be directed to the real object. |
| 20 | ON_CALL(*this, getBaseBlobId) |
| 21 | .WillByDefault(Invoke(&real_store_, &BinaryStore::getBaseBlobId)); |
| 22 | ON_CALL(*this, getBlobIds) |
| 23 | .WillByDefault(Invoke(&real_store_, &BinaryStore::getBlobIds)); |
| 24 | } |
Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 25 | MOCK_CONST_METHOD0(getBaseBlobId, std::string()); |
Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 26 | MOCK_CONST_METHOD0(getBlobIds, std::vector<std::string>()); |
Kun Yi | 38146a0 | 2018-12-18 21:54:26 -0800 | [diff] [blame] | 27 | MOCK_METHOD2(openOrCreateBlob, bool(const std::string&, uint16_t)); |
Kun Yi | c0adbc3 | 2018-12-18 22:35:29 -0800 | [diff] [blame] | 28 | MOCK_METHOD1(deleteBlob, bool(const std::string&)); |
Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 29 | MOCK_METHOD2(read, std::vector<uint8_t>(uint32_t, uint32_t)); |
| 30 | MOCK_METHOD2(write, bool(uint32_t, const std::vector<uint8_t>&)); |
| 31 | MOCK_METHOD0(commit, bool()); |
| 32 | MOCK_METHOD0(close, bool()); |
| 33 | MOCK_METHOD0(stat, bool()); |
Kun Yi | 64dc05c | 2018-12-19 13:19:03 -0800 | [diff] [blame] | 34 | |
| 35 | private: |
| 36 | BinaryStore real_store_; |
Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | } // namespace binstore |