cserver/tests/dependencies.cpp

35 lines
1.1 KiB
C++
Raw Normal View History

2024-06-27 02:14:54 +00:00
#include <gtest/gtest.h>
#include <cserver/engine/components.hpp>
#include <boost/type_index.hpp>
struct SomeComponent {
static constexpr utempl::ConstexprString kName = "some";
constexpr SomeComponent(auto, auto&) {};
};
struct SomeOtherComponent {
SomeComponent& component;
static constexpr utempl::ConstexprString kName = "other";
constexpr SomeOtherComponent(auto, auto& context) : component(context.template FindComponent<"some">()) {
};
};
TEST(Dependencies, Get) {
constexpr auto dependencies = cserver::ServiceContextBuilder{}
.Append<SomeOtherComponent>()
2024-06-27 02:18:40 +00:00
.Append<SomeComponent>()
2024-06-27 02:14:54 +00:00
.Sort()
.GetDependencyGraph();
using Need = const cserver::DependencyGraph<
cserver::DependencyGraphElement<
2024-06-27 06:31:00 +00:00
"some",
{}>,
2024-06-27 02:14:54 +00:00
cserver::DependencyGraphElement<
2024-06-27 06:31:00 +00:00
"other",
{utempl::ConstexprString{"some"}}>>;
2024-06-27 02:14:54 +00:00
EXPECT_EQ(boost::typeindex::type_id<decltype(dependencies)>().pretty_name(),
boost::typeindex::type_id<Need>().pretty_name());
};