use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testReceiveEventRequiringMultipleComponents.
@Test
public void testReceiveEventRequiringMultipleComponents() {
entity.addComponent(new StringComponent());
entity.addComponent(new IntegerComponent());
TestCompoundComponentEventHandler handler = new TestCompoundComponentEventHandler();
eventSystem.registerEventHandler(handler);
TestEvent event = new TestEvent();
eventSystem.send(entity, event);
assertEquals(1, handler.receivedList.size());
assertEquals(event, handler.receivedList.get(0).event);
assertEquals(entity, handler.receivedList.get(0).entity);
}
use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testChildEvent.
@Test
public void testChildEvent() {
entity.addComponent(new IntegerComponent());
TestEventHandler handler = new TestEventHandler();
eventSystem.registerEvent(new ResourceUrn("test:childEvent"), TestChildEvent.class);
eventSystem.registerEventHandler(handler);
TestChildEvent event = new TestChildEvent();
eventSystem.send(entity, event);
assertEquals(1, handler.childEventReceived.size());
assertEquals(1, handler.receivedList.size());
}
use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentsNotAlteredIfBlockInSameFamily.
@Test
public void testComponentsNotAlteredIfBlockInSameFamily() {
worldProvider.setBlock(new Vector3i(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new IntegerComponent());
worldProvider.setBlock(new Vector3i(), blockInFamilyTwo);
assertNotNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testEntityExtraComponentsRemovedBeforeCleanUpForBlocksWithPrefabs.
@Test
public void testEntityExtraComponentsRemovedBeforeCleanUpForBlocksWithPrefabs() {
worldStub.setBlock(new Vector3i(), blockWithString);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new IntegerComponent(1));
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), IntegerComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
Aggregations