2024-06-27 02:14:54 +00:00
|
|
|
#include <gtest/gtest.h>
|
2024-07-07 00:48:00 +00:00
|
|
|
|
2024-06-27 02:14:54 +00:00
|
|
|
#include <cserver/engine/components.hpp>
|
2024-07-03 12:41:23 +00:00
|
|
|
#include <nameof.hpp>
|
2024-06-27 02:14:54 +00:00
|
|
|
|
|
|
|
struct SomeComponent {
|
|
|
|
static constexpr utempl::ConstexprString kName = "some";
|
2024-07-07 00:48:00 +00:00
|
|
|
explicit constexpr SomeComponent(auto&) {};
|
2024-06-27 02:14:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SomeOtherComponent {
|
|
|
|
SomeComponent& component;
|
|
|
|
static constexpr utempl::ConstexprString kName = "other";
|
2024-07-07 00:48:00 +00:00
|
|
|
explicit constexpr SomeOtherComponent(auto& context) : component(context.template FindComponent<"some">()) {};
|
2024-06-27 02:14:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST(Dependencies, Get) {
|
|
|
|
constexpr auto dependencies = cserver::ServiceContextBuilder{}
|
2024-07-07 00:48:00 +00:00
|
|
|
.Append<SomeOtherComponent>()
|
|
|
|
.Append<SomeComponent>()
|
|
|
|
.AppendConfigParam<"threads", 8>()
|
|
|
|
.Sort()
|
|
|
|
.GetDependencyGraph();
|
|
|
|
using Need = const cserver::DependencyGraph<cserver::DependencyGraphElement<"some", {}>,
|
|
|
|
cserver::DependencyGraphElement<"other", {utempl::ConstexprString{"some"}}>>;
|
|
|
|
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)), NAMEOF_TYPE(Need));
|
2024-06-27 02:14:54 +00:00
|
|
|
};
|