Search in sources :

Example 46 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class CollisionCategoryConfigTest method testNoNode.

/**
 * Test no node.
 */
@Test
void testNoNode() {
    final Xml root = new Xml("categories");
    assertTrue(CollisionCategoryConfig.imports(root).isEmpty());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 47 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class CollisionCategoryConfigTest method testCategory.

/**
 * Test category.
 */
@Test
void testCategory() {
    final Xml root = new Xml("categories");
    CollisionCategoryConfig.exports(root, category);
    CollisionCategoryConfig.exports(root, new CollisionCategory("name2", Axis.X, 1, 2, true, Arrays.asList(group)));
    final Collection<CollisionCategory> imported = CollisionCategoryConfig.imports(root);
    assertEquals(category, imported.iterator().next());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 48 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class PathfindableConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final Map<String, PathData> map = new HashMap<>();
    final PathData data = new PathData("category", 1.0, true, Arrays.asList(MovementTile.UP));
    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);
    assertEquals(map, PathfindableConfig.imports(new Configurer(media)));
    assertTrue(media.getFile().delete());
}
Also used : HashMap(java.util.HashMap) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 49 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class PathfindableConfigTest method testWrongMovement.

/**
 * Test with wrong movement.
 */
@Test
void testWrongMovement() {
    final PathData data = new PathData("category", 1.0, true, EnumSet.noneOf(MovementTile.class));
    final Xml path = PathfindableConfig.exportPathData(data);
    final Xml movement = path.createChild(PathfindableConfig.NODE_MOVEMENT);
    movement.setText("VOID");
    final Xml root = new Xml("test");
    final Xml node = root.createChild(PathfindableConfig.NODE_PATHFINDABLE);
    node.add(path);
    final Media media = Medias.create("pathfindable.xml");
    root.save(media);
    assertCause(() -> PathfindableConfig.imports(new Configurer(media)), IllegalArgumentException.class);
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 50 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class CollisionCategoryConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final Media formulasConfig = UtilConfig.createFormulaConfig(formula);
    final Media groupsConfig = UtilConfig.createGroupsConfig(group);
    mapCollision.loadCollisions(formulasConfig, groupsConfig);
    final Xml root = new Xml("categories");
    CollisionCategoryConfig.exports(root, category);
    final Media media = Medias.create("Object.xml");
    root.save(media);
    final Collection<CollisionCategory> imported = CollisionCategoryConfig.imports(new Configurer(media), mapCollision);
    assertEquals(category, imported.iterator().next());
    assertTrue(formulasConfig.getFile().delete());
    assertTrue(groupsConfig.getFile().delete());
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Aggregations

Xml (com.b3dgs.lionengine.Xml)133 Test (org.junit.jupiter.api.Test)73 Media (com.b3dgs.lionengine.Media)63 Configurer (com.b3dgs.lionengine.game.Configurer)25 Setup (com.b3dgs.lionengine.game.feature.Setup)11 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 Animation (com.b3dgs.lionengine.Animation)4 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)4 Feature (com.b3dgs.lionengine.game.Feature)3 Force (com.b3dgs.lionengine.game.Force)3 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)3 Services (com.b3dgs.lionengine.game.feature.Services)3 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)3 Map (java.util.Map)3 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 Origin (com.b3dgs.lionengine.Origin)1 UtilAssert.assertThrows (com.b3dgs.lionengine.UtilAssert.assertThrows)1 XmlReader (com.b3dgs.lionengine.XmlReader)1 Orientation (com.b3dgs.lionengine.game.Orientation)1