Search in sources :

Example 1 with TestEntity

use of ilargia.entitas.utils.TestEntity in project Entitas-Java by Rubentxu.

the class ContextTest method getReusableEntitiesCountTest.

@Test
public void getReusableEntitiesCountTest() {
    TestEntity entity2 = context.createEntity();
    assertEquals(0, context.getReusableEntitiesCount());
    context.destroyEntity(entity2);
    assertEquals(2, context.getReusableEntitiesCount());
}
Also used : TestEntity(ilargia.entitas.utils.TestEntity) Test(org.junit.Test)

Example 2 with TestEntity

use of ilargia.entitas.utils.TestEntity in project Entitas-Java by Rubentxu.

the class ContextTest method updateGroupsComponentReplacedTest.

@Test
public void updateGroupsComponentReplacedTest() {
    Position position = new Position();
    Position position2 = new Position();
    Group<TestEntity> groupE = context.getGroup(TestMatcher.Position());
    groupE.OnEntityUpdated((IGroup<TestEntity> group, final TestEntity entity, int index, IComponent previousComponent, IComponent nc) -> {
        System.out.println("Removed...........");
        assertEquals(position2, nc);
    });
    entity.addComponent(TestComponentIds.Position, position);
    context.updateGroupsComponentReplaced(entity, TestComponentIds.Position, position, position2, context._groupsForIndex);
}
Also used : TestEntity(ilargia.entitas.utils.TestEntity) Position(ilargia.entitas.components.Position) IComponent(ilargia.entitas.api.IComponent) IGroup(ilargia.entitas.api.IGroup) Test(org.junit.Test)

Example 3 with TestEntity

use of ilargia.entitas.utils.TestEntity in project Entitas-Java by Rubentxu.

the class EntityTest method setUp.

@Before
public void setUp() throws Exception {
    createCollections();
    _componentPools = new Stack[10];
    EntitasCache cache = new EntitasCache();
    entity = new TestEntity();
    entity.initialize(0, 10, _componentPools, new ContextInfo("Test", TestComponentIds.componentNames(), TestComponentIds.componentTypes()));
    entity.clearEventsListener();
    entity.reactivate(0);
    entity.addComponent(TestComponentIds.Position, new Position(100, 100));
    entity.addComponent(TestComponentIds.View, new View(1));
}
Also used : TestEntity(ilargia.entitas.utils.TestEntity) EntitasCache(ilargia.entitas.caching.EntitasCache) Position(ilargia.entitas.components.Position) View(ilargia.entitas.components.View) ContextInfo(ilargia.entitas.api.ContextInfo) Before(org.junit.Before)

Example 4 with TestEntity

use of ilargia.entitas.utils.TestEntity in project Entitas-Java by Rubentxu.

the class ContextTest method getRetainedEntitiesCountTest.

@Test
public void getRetainedEntitiesCountTest() {
    TestEntity entity2 = context.createEntity();
    entity.retain(new Object());
    context.destroyEntity(entity);
    assertEquals(1, context.getRetainedEntitiesCount());
    context.destroyEntity(entity2);
    assertEquals(1, context.getRetainedEntitiesCount());
}
Also used : TestEntity(ilargia.entitas.utils.TestEntity) Test(org.junit.Test)

Example 5 with TestEntity

use of ilargia.entitas.utils.TestEntity in project Entitas-Java by Rubentxu.

the class ContextTest method entityIsNotRetainedByOwnerExceptionTest.

@Test(expected = ContextDoesNotContainEntityException.class)
public void entityIsNotRetainedByOwnerExceptionTest() {
    TestEntity entity2 = new TestEntity();
    entity2.initialize(0, 100, null, null, null);
    context.destroyEntity(entity2);
}
Also used : TestEntity(ilargia.entitas.utils.TestEntity) Test(org.junit.Test)

Aggregations

TestEntity (ilargia.entitas.utils.TestEntity)7 Test (org.junit.Test)5 Position (ilargia.entitas.components.Position)4 ContextInfo (ilargia.entitas.api.ContextInfo)2 View (ilargia.entitas.components.View)2 Before (org.junit.Before)2 IComponent (ilargia.entitas.api.IComponent)1 IGroup (ilargia.entitas.api.IGroup)1 EntitasCache (ilargia.entitas.caching.EntitasCache)1 Group (ilargia.entitas.group.Group)1