Завершение контроллера

This commit is contained in:
Антон
2025-08-24 08:25:41 +03:00
parent d53814c3cc
commit 029f9c2fd3
3 changed files with 24 additions and 15 deletions
+13 -8
View File
@@ -15,6 +15,10 @@ using namespace boost;
using namespace std;
using namespace uad;
using IControllerMock = Controller<beast::http::string_body,
std::allocator<char>,
beast::http::string_body>;
class MockExecutor : public IExecutor<beast::http::string_body,
std::allocator<char>,
beast::http::string_body>
@@ -33,9 +37,7 @@ public:
BOOST_AUTO_TEST_CASE(Should_Be_Initiated_With_No_Executors)
{
Controller<beast::http::string_body,
std::allocator<char>,
beast::http::string_body> my_controller;
IControllerMock my_controller;
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::get).has_value());
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::post).has_value());
@@ -47,13 +49,16 @@ BOOST_AUTO_TEST_CASE(Should_Be_Initiated_With_No_Executors)
BOOST_AUTO_TEST_CASE(Should_Be_Initiated_With_Unordered_Map_HTTP_Methods_To_Executors)
{
std::unordered_map<boost::beast::http::verb, std::unique_ptr<IExecutor<beast::http::string_body, std::allocator<char>, beast::http::string_body>>> executors;
IControllerMock::HTTPMethodsToExecutors executors;
executors[beast::http::verb::get] = make_unique<MockExecutor>();
executors[beast::http::verb::get] = make_shared<MockExecutor>();
executors[beast::http::verb::post] = make_shared<MockExecutor>();
executors[beast::http::verb::put] = make_shared<MockExecutor>();
executors[beast::http::verb::delete_] = make_shared<MockExecutor>();
executors[beast::http::verb::head] = make_shared<MockExecutor>();
executors[beast::http::verb::options] = make_shared<MockExecutor>();
Controller<beast::http::string_body,
std::allocator<char>,
beast::http::string_body> my_controller(std::move(executors));
IControllerMock my_controller(std::move(executors));
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::get).has_value());
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::post).has_value());