Files
NazaraEngine/tests/SDK/NDK/BaseSystem.cpp
Gawaboumga 9eba331f34 Documentation for module 'NDK'
Former-commit-id: 63e1cac538c577a1f1aafa71fa7eef69a6d4daab [formerly b2d8769fd02a0e7d9c476d4ad7be1988a1fd6789] [formerly 636b5cb79bcb8da44d9aa45ba1023565bcf29f0d [formerly a2361ec2b8679d4d4ba096e543b5d4b91825dd62]]
Former-commit-id: d402d35477f9db0135c553d55c401939426bf62d [formerly 607336ea0f42731e4604f3a8c2df06f3aecfc401]
Former-commit-id: 69e23cd6c06723486de5e4641ce810012dac66da
2016-08-21 13:48:52 +02:00

64 lines
1.3 KiB
C++

#include <NDK/System.hpp>
#include <NDK/Components/NodeComponent.hpp>
#include <NDK/Components/VelocityComponent.hpp>
#include <NDK/World.hpp>
#include <Catch/catch.hpp>
namespace
{
class TestSystem : public Ndk::System<TestSystem>
{
public:
TestSystem()
{
Requires<Ndk::VelocityComponent>();
Excludes<Ndk::NodeComponent>();
}
~TestSystem() = default;
static Ndk::SystemIndex systemIndex;
private:
void OnUpdate(float elapsedTime) override
{
}
};
Ndk::SystemIndex TestSystem::systemIndex;
}
SCENARIO("BaseSystem", "[NDK][BASESYSTEM]")
{
GIVEN("Our TestSystem")
{
Ndk::World world;
Ndk::BaseSystem& system = world.AddSystem<TestSystem>();
REQUIRE(&system.GetWorld() == &world);
WHEN("We add an entity")
{
const Ndk::EntityHandle& entity = world.CreateEntity();
entity->AddComponent<Ndk::VelocityComponent>();
THEN("System should have it")
{
world.Update(1.f);
REQUIRE(system.HasEntity(entity));
}
}
WHEN("We add an entity with excluded component")
{
const Ndk::EntityHandle& entity = world.CreateEntity();
entity->AddComponent<Ndk::VelocityComponent>();
entity->AddComponent<Ndk::NodeComponent>();
THEN("System should not have it")
{
world.Update(1.f);
REQUIRE(!system.HasEntity(entity));
}
}
}
}