Entity e = new Entity(null, 0);
unittest_FooComponent f = new unittest_FooComponent();
e.add(f); // First time the component is added, no error
assertThrown!EntityComponentHandlingException(e.add(f), "Second time the same type is added");
e.remove!unittest_FooComponent; // First time the component is removed, no error
assertThrown!EntityComponentHandlingException(e.remove!unittest_FooComponent,
"Second time the type is being accessed");
Entity e = new Entity(null, 0);
unittest_FooComponent foo = new unittest_FooComponent();
e.add(foo); // Entity components == [foo]
assertTrue(e.contains!unittest_FooComponent);
assertTrue(e.containsAll!unittest_FooComponent);
assertTrue(e.containsAny!(unittest_FooComponent, unittest_BarComponent), "Entity contains an unittets_FooComponent");
assertFalse(e.containsAll!(unittest_FooComponent, unittest_BarComponent),
"Entity doesn't contain an unittest_BarComponent");
assertFalse(e.containsAny!(unittest_BarComponent));
import std.range.primitives;
auto arr = e.getAll;
import std.traits : ReturnType;
assertTrue(is(ReturnType!(e.get!unittest_FooComponent) == unittest_FooComponent), "Returns the original type");
assertTrue(foo is e.get!unittest_FooComponent);
assertTrue(e.get!unittest_BarComponent is null, "Entity doesn't contain a type unittest_BarComponent component");
assertEquals(1, arr.length, "Entity should contain only 1 component");
assertTrue(is(typeof(arr.front) == IComponent));
Entity e = new Entity(null, 0);
e.add(new unittest_FooComponent());
e.clear();
assertEquals(0, e.getAll().length);
Entity e = new Entity(null, 0);
e.add!unittest_FooComponent;
assertEquals(int.init, e.get!unittest_FooComponent.a);
e.modify!unittest_FooComponent(4);
assertEquals(4, e.get!unittest_FooComponent.a);
assertThrown!EntityComponentHandlingException(e.modify!unittest_BarComponent(5));