use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollidableFramedModelTest method beforeTests.
/**
* Prepare test.
*/
@BeforeAll
public static void beforeTests() {
Graphics.setFactoryGraphic(new FactoryGraphicMock());
Medias.setResourcesDirectory(System.getProperty("java.io.tmpdir"));
config = UtilSetup.createConfig(CollidableFramedModelTest.class);
final Map<Integer, Collection<Collision>> collisions = new HashMap<>();
collisions.put(Integer.valueOf(1), Arrays.asList(new Collision("anim%1", 0, 0, 2, 2, false)));
final Xml root = new Xml(config);
AnimationConfig.exports(root, new Animation("anim", 1, 2, 1.0, false, false));
final Xml framed = root.getChildXml(AnimationConfig.NODE_ANIMATIONS).getChildXml(AnimationConfig.NODE_ANIMATION);
CollidableFramedConfig.exports(framed, collisions);
root.save(config);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class AttackerModelTest method testConfig.
/**
* Test the config.
*/
@Test
void testConfig() {
final int damagesMin = 1;
final int damagesMax = 2;
final int distanceMin = 1;
final int distanceMax = 2;
final int frame = 1;
final int time = 100;
final Media media = UtilTransformable.createMedia(AttackerModelTest.class);
final Xml xml = new Xml(media);
xml.add(AttackerConfig.exports(new AttackerConfig(time, distanceMin, distanceMax, damagesMin, damagesMax)));
xml.save(media);
final AttackerModel attacker = new AttackerModel(services, new Setup(media));
attacker.setAttackFrame(frame);
assertTrue(attacker.getAttackDamages() >= damagesMin);
assertTrue(attacker.getAttackDamages() <= damagesMax);
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FeaturableConfigTest method testDefaultClass.
/**
* Test with default class.
*/
@Test
void testDefaultClass() {
final Xml root = new Xml("test");
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(new FeaturableConfig(FeaturableModel.class.getName(), ""), FeaturableConfig.imports(new Xml(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FeaturableConfigTest method testGetFeaturesUnknown.
/**
* Test with unknown feature class.
*/
@Test
void testGetFeaturesUnknown() {
final Xml root = new Xml("test");
root.createChild(FeaturableConfig.NODE_FEATURES).createChild(FeaturableConfig.NODE_FEATURE).setText(Feature.class.getName());
final Media media = Medias.create("Object.xml");
root.save(media);
assertCause(() -> FeaturableConfig.getFeatures(ClassLoader.getSystemClassLoader(), new Services(), new Setup(media)), NoSuchMethodException.class);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FeaturableConfigTest method testDefaultSetup.
/**
* Test with default setup.
*/
@Test
void testDefaultSetup() {
final Xml root = new Xml("test");
root.add(FeaturableConfig.exportClass("clazz"));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(new FeaturableConfig("clazz", ""), FeaturableConfig.imports(new Xml(media)));
assertTrue(media.getFile().delete());
}
Aggregations