use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class CollidableConfigTest method testDefaultGroup.
/**
* Test with default group.
*/
@Test
void testDefaultGroup() {
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
root.save(media);
assertEquals(CollidableConfig.DEFAULT_GROUP, CollidableConfig.imports(new Configurer(media)).getGroup());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class CollidableConfigTest method testInvalidGroup.
/**
* Test with invalid group.
*/
@Test
void testInvalidGroup() {
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
final Xml node = root.createChild(CollidableConfig.NODE_COLLIDABLE);
node.writeString(CollidableConfig.ATT_GROUP, "a");
root.save(media);
assertCause(() -> CollidableConfig.imports(new Configurer(media)), NumberFormatException.class);
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class CollisionConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Xml root = new Xml(Constant.XML_PREFIX + FeaturableConfig.NODE_FEATURABLE);
final Collision collision = new Collision("test", 0, 1, 2, 3, true);
CollisionConfig.exports(root, collision);
final Media media = Medias.create("collision.xml");
root.save(media);
final CollisionConfig config = CollisionConfig.imports(new Configurer(media));
final Collision imported = config.getCollision("test");
assertEquals("test", imported.getName());
assertEquals(0, imported.getOffsetX());
assertEquals(1, imported.getOffsetY());
assertEquals(2, imported.getWidth());
assertEquals(3, imported.getHeight());
assertTrue(imported.hasMirror());
assertFalse(config.getCollisions().isEmpty());
assertEquals(collision, config.getCollision("test"));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class PathfindableConfigTest method testNoMovements.
/**
* Test without movements.
*/
@Test
void testNoMovements() {
final Map<String, PathData> map = new HashMap<>();
final PathData data = new PathData("category", 1.0, true, EnumSet.noneOf(MovementTile.class));
map.put(data.getName(), data);
final Xml root = new Xml("test");
root.add(PathfindableConfig.exports(map));
final Media media = Medias.create("pathfindable.xml");
root.save(media);
final Map<String, PathData> imported = PathfindableConfig.imports(new Configurer(media));
assertTrue(imported.get(data.getName()).getAllowedMovements().isEmpty());
assertEquals(map, imported);
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class PathfindableConfigTest method testNoNode.
/**
* Test without node.
*/
@Test
void testNoNode() {
final Xml root = new Xml("test");
final Media media = Medias.create("pathfindable.xml");
root.save(media);
assertTrue(PathfindableConfig.imports(new Configurer(media)).isEmpty());
assertTrue(media.getFile().delete());
}
Aggregations