Skip to content

Commit ace11d1

Browse files
committed
test: added WaypointComponentTest
1 parent ef85470 commit ace11d1

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* FXGL - JavaFX Game Library. The MIT License (MIT).
3+
* Copyright (c) AlmasB (almaslvl@gmail.com).
4+
* See LICENSE for details.
5+
*/
6+
7+
package com.almasb.fxgl.dsl.components
8+
9+
import com.almasb.fxgl.entity.Entity
10+
import javafx.geometry.Point2D
11+
import org.hamcrest.CoreMatchers.`is`
12+
import org.hamcrest.MatcherAssert.assertThat
13+
import org.junit.jupiter.api.Assertions.assertFalse
14+
import org.junit.jupiter.api.Assertions.assertTrue
15+
import org.junit.jupiter.api.Test
16+
17+
/**
18+
*
19+
*
20+
* @author Almas Baimagambetov (almaslvl@gmail.com)
21+
*/
22+
class WaypointMoveComponentTest {
23+
24+
@Test
25+
fun `Moving via WaypointComponent`() {
26+
val comp = WaypointMoveComponent(100.0, listOf(Point2D(20.0, 50.0), Point2D(40.0, 50.0)))
27+
28+
val e = Entity()
29+
e.addComponent(comp)
30+
31+
assertFalse(comp.atDestinationProperty().value)
32+
33+
comp.onUpdate(5.0)
34+
assertThat(e.position, `is`(Point2D(20.0, 50.0)))
35+
36+
assertFalse(comp.atDestinationProperty().value)
37+
38+
comp.onUpdate(5.0)
39+
assertThat(e.position, `is`(Point2D(40.0, 50.0)))
40+
41+
assertTrue(comp.atDestinationProperty().value)
42+
}
43+
}

0 commit comments

Comments
 (0)