Loading...
Searching...
No Matches
mock_socket.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include <string>
23
24#include "gmock/gmock.h"
26
27namespace resdb {
28
29class MockSocket : public Socket {
30 public:
31 MOCK_METHOD(int, Connect, (const std::string&, int), (override));
32 MOCK_METHOD(int, Listen, (const std::string&, int), (override));
33 MOCK_METHOD(void, ReInit, (), (override));
34 MOCK_METHOD(void, Close, (), (override));
35 MOCK_METHOD(std::unique_ptr<Socket>, Accept, (), (override));
36 MOCK_METHOD(int, Send, (const std::string&), (override));
37 MOCK_METHOD(int, Recv, (void**, size_t*), (override));
38 MOCK_METHOD(int, GetBindingPort, (), (override));
39
40 MOCK_METHOD(int, SetAsync, (bool), (override));
41};
42
43} // namespace resdb
MOCK_METHOD(int, SetAsync,(bool),(override))
MOCK_METHOD(int, GetBindingPort,(),(override))
MOCK_METHOD(void, Close,(),(override))
MOCK_METHOD(int, Send,(const std::string &),(override))
MOCK_METHOD(void, ReInit,(),(override))
MOCK_METHOD(int, Listen,(const std::string &, int),(override))
MOCK_METHOD(std::unique_ptr< Socket >, Accept,(),(override))
MOCK_METHOD(int, Connect,(const std::string &, int),(override))
MOCK_METHOD(int, Recv,(void **, size_t *),(override))
virtual int Listen(const std::string &ip, int port)=0
virtual int Recv(void **buf, size_t *len)=0
virtual int Send(const std::string &data)=0
virtual int Connect(const std::string &ip, int port)=0
virtual int GetBindingPort()=0
virtual void ReInit()=0
virtual std::unique_ptr< Socket > Accept()=0
virtual void Close()=0
virtual int SetAsync(bool is_open=true)
Definition socket.h:48