blob: eae08fe5e91b9862f3838d5ff865c55f68954051 [file] [log] [blame]
Kun Yi68c81142018-12-18 11:17:14 -08001#pragma once
2
3#include "binarystore.hpp"
4
5#include <gmock/gmock.h>
6
Kun Yi64dc05c2018-12-19 13:19:03 -08007using ::testing::Invoke;
8
Kun Yi68c81142018-12-18 11:17:14 -08009namespace binstore
10{
11
12class MockBinaryStore : public BinaryStoreInterface
13{
14 public:
Kun Yi64dc05c2018-12-19 13:19:03 -080015 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 Yi68c81142018-12-18 11:17:14 -080025 MOCK_CONST_METHOD0(getBaseBlobId, std::string());
Kun Yi68c81142018-12-18 11:17:14 -080026 MOCK_CONST_METHOD0(getBlobIds, std::vector<std::string>());
Kun Yi38146a02018-12-18 21:54:26 -080027 MOCK_METHOD2(openOrCreateBlob, bool(const std::string&, uint16_t));
Kun Yic0adbc32018-12-18 22:35:29 -080028 MOCK_METHOD1(deleteBlob, bool(const std::string&));
Kun Yi68c81142018-12-18 11:17:14 -080029 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 Yi64dc05c2018-12-19 13:19:03 -080034
35 private:
36 BinaryStore real_store_;
Kun Yi68c81142018-12-18 11:17:14 -080037};
38
39} // namespace binstore