Package com.artemis.managers

Source Code of com.artemis.managers.GroupManagerTest

package com.artemis.managers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import org.junit.Before;
import org.junit.Test;

import com.artemis.Entity;
import com.artemis.World;

public class GroupManagerTest {
  private static final String GROUPIE = "groupie";
  private static final String GROUPIE2 = "groupie2";
 
  private World world;
  private GroupManager gm;

  @Before
  public void setUp() throws Exception {
    world = new World();
    gm = world.setManager(new GroupManager());
    world.initialize();
  }
 
  @Test
  public void added_entities_should_only_occur_once() {
    Entity entity = world.createEntity();
    gm.add(entity, GROUPIE);
    gm.add(entity, GROUPIE);

    assertEquals(1, gm.getEntities(GROUPIE).size());
  }
 
  @Test
  public void deleted_entities_should_be_removed() {
    Entity entity = world.createEntity();
    gm.add(entity, GROUPIE);

    assertEquals(1, gm.getEntities(GROUPIE).size());

    entity.deleteFromWorld();
    world.process();
    assertEquals(0, gm.getEntities(GROUPIE).size());
    assertFalse(gm.isInAnyGroup(entity));
  }
 
  @Test
  public void deleted_entities_should_be_removed_from_all_groups() {
    Entity entity = world.createEntity();
    gm.add(entity, GROUPIE);
    gm.add(entity, GROUPIE2);
   
    assertEquals(1, gm.getEntities(GROUPIE).size());
    assertEquals(1, gm.getEntities(GROUPIE2).size());
   
    entity.deleteFromWorld();
    world.process();
   
    assertEquals(0, gm.getEntities(GROUPIE).size());
    assertEquals(0, gm.getEntities(GROUPIE2).size());
    assertFalse(gm.isInAnyGroup(entity));
  }
}
TOP

Related Classes of com.artemis.managers.GroupManagerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.