use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testNoReceiveEventWhenMissingComponents.
@Test
public void testNoReceiveEventWhenMissingComponents() {
entity.addComponent(new StringComponent());
TestCompoundComponentEventHandler handler = new TestCompoundComponentEventHandler();
eventSystem.registerEventHandler(handler);
TestEvent event = new TestEvent();
eventSystem.send(entity, event);
assertEquals(0, handler.receivedList.size());
}
use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testChangeComponentEventSentWhenSave.
@Test
public void testChangeComponentEventSentWhenSave() {
EventSystem eventSystem = mock(EventSystem.class);
EntityRef entity1 = entityManager.create();
StringComponent comp = entity1.addComponent(new StringComponent());
entityManager.setEventSystem(eventSystem);
entity1.saveComponent(comp);
verify(eventSystem).send(entity1, OnChangedComponent.newInstance(), comp);
}
use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testRemoveComponent.
@Test
public void testRemoveComponent() {
EntityRef entity = entityManager.create();
StringComponent comp = new StringComponent();
entity.addComponent(comp);
entity.removeComponent(StringComponent.class);
assertNull(entity.getComponent(StringComponent.class));
}
use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testIterateEntitiesDoesNotFindEntityMissingAComponent.
@Test
public void testIterateEntitiesDoesNotFindEntityMissingAComponent() {
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
List<EntityRef> results = Lists.newArrayList(entityManager.getEntitiesWith(StringComponent.class, IntegerComponent.class));
assertEquals(Collections.<EntityRef>emptyList(), results);
}
use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testReplaceComponent.
@Test
public void testReplaceComponent() {
EntityRef entity = entityManager.create();
StringComponent comp = new StringComponent();
comp.value = "Hello";
StringComponent comp2 = new StringComponent();
comp2.value = "Goodbye";
entity.addComponent(comp);
entity.addComponent(comp2);
assertEquals(comp2, entity.getComponent(StringComponent.class));
}
Aggregations