irccd  3.0.3
mock_stream.hpp
1 /*
2  * mock_stream.hpp -- mock stream
3  *
4  * Copyright (c) 2013-2019 David Demelier <markand@malikania.fr>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef IRCCD_TEST_MOCK_STREAM_HPP
20 #define IRCCD_TEST_MOCK_STREAM_HPP
21 
27 #include <irccd/stream.hpp>
28 
29 #include "mock.hpp"
30 
31 namespace irccd::test {
32 
36 class mock_stream : public stream, public mock {
37 public:
41  void recv(recv_handler handler) override;
42 
46  void send(const nlohmann::json& json, send_handler handler) override;
47 };
48 
49 } // !irccd::test
50 
51 #endif // !IRCCD_TEST_MOCK_STREAM_HPP
irccd::test::mock_stream::send
void send(const nlohmann::json &json, send_handler handler) override
irccd::test::mock
Keep track of function invocations.
Definition: mock.hpp:38
irccd::stream::recv_handler
std::function< void(std::error_code, nlohmann::json)> recv_handler
Read completion handler.
Definition: stream.hpp:63
irccd::stream::send_handler
std::function< void(std::error_code)> send_handler
Write completion handler.
Definition: stream.hpp:68
irccd::stream
Abstract stream interface.
Definition: stream.hpp:58
irccd::test::mock_stream
Mock stream.
Definition: mock_stream.hpp:36
irccd::test
Namespace for unit tests.
Definition: broken_plugin.hpp:29
irccd::test::mock_stream::recv
void recv(recv_handler handler) override