Search in sources :

Example 51 with Xml

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

the class CollisionConstraintConfigTest method testExportsImportsEmptyConstraints.

/**
 * Test with empty constraint.
 */
@Test
void testExportsImportsEmptyConstraints() {
    final Xml root = new Xml("constraint");
    final CollisionConstraint constraint = new CollisionConstraint();
    CollisionConstraintConfig.exports(root, constraint);
    assertEquals(constraint, CollisionConstraintConfig.imports(root));
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 52 with Xml

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

the class CollisionFormulaConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final Xml root = new Xml("formula");
    CollisionFormulaConfig.exports(root, formula);
    final Media config = Medias.create("formulas.xml");
    root.save(config);
    final CollisionFormulaConfig imported = CollisionFormulaConfig.imports(config);
    assertEquals("formula", imported.getFormulas().keySet().iterator().next());
    assertEquals(formula, imported.getFormula("formula"));
    assertTrue(config.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Example 53 with Xml

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

the class CollisionFunctionConfigTest method testImportFunctionInvalid.

/**
 * Test import with invalid function.
 */
@Test
void testImportFunctionInvalid() {
    final Xml root = new Xml("function");
    final CollisionFunction function = new CollisionFunctionLinear(2.0, 3.0);
    CollisionFunctionConfig.exports(root, function);
    root.getChildXml(CollisionFunctionConfig.FUNCTION).writeString(CollisionFunctionConfig.TYPE, "void");
    assertThrows(() -> CollisionFunctionConfig.imports(root), XmlReader.ERROR_ENUM + "void");
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 54 with Xml

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

the class CollisionFunctionConfigTest method testFunction.

/**
 * Test exports imports.
 */
@Test
void testFunction() {
    final Xml root = new Xml("function");
    final CollisionFunction function = new CollisionFunctionLinear(2.0, 3.0);
    CollisionFunctionConfig.exports(root, function);
    final CollisionFunction imported = CollisionFunctionConfig.imports(root);
    assertEquals(function, imported);
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 55 with Xml

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

the class TransitionsConfig method exportTiles.

/**
 * Export all tiles for the transition.
 *
 * @param nodeTransition The transition node (must not be <code>null</code>).
 * @param tiles The transition tiles (must not be <code>null</code>).
 */
private static void exportTiles(Xml nodeTransition, Collection<Integer> tiles) {
    for (final Integer tile : tiles) {
        final Xml nodeTile = TileConfig.exports(tile.intValue());
        nodeTransition.add(nodeTile);
    }
}
Also used : Xml(com.b3dgs.lionengine.Xml)

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