#ifdef WIN32 #include #endif #define BOOST_TEST_MODULE Controllers #include #include "./../../src/endpoints_handlers/Controller.h" #include #include using namespace boost; using namespace std; using namespace uad; class MockExecutor : public IExecutor, beast::http::string_body> { public: beast::http::response operator ()( beast::http::request>>&& req ) override { boost::beast::http::response res{ boost::beast::http::status::not_found, req.version()}; return res; } }; BOOST_AUTO_TEST_CASE(Should_Be_Initiated_With_No_Executors) { Controller, beast::http::string_body> my_controller; BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::get).has_value()); BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::post).has_value()); BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::put).has_value()); BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::delete_).has_value()); BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::head).has_value()); BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::options).has_value()); } BOOST_AUTO_TEST_CASE(Should_Be_Initiated_With_Unordered_Map_HTTP_Methods_To_Executors) { std::unordered_map, beast::http::string_body>>> executors; executors[beast::http::verb::get] = make_unique(); Controller, beast::http::string_body> 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()); BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::put).has_value()); BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::delete_).has_value()); BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::head).has_value()); BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::options).has_value()); }