-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
fxgl/src/test/kotlin/com/almasb/fxgl/dsl/components/WaypointMoveComponentTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* FXGL - JavaFX Game Library. The MIT License (MIT). | ||
* Copyright (c) AlmasB ([email protected]). | ||
* See LICENSE for details. | ||
*/ | ||
|
||
package com.almasb.fxgl.dsl.components | ||
|
||
import com.almasb.fxgl.entity.Entity | ||
import javafx.geometry.Point2D | ||
import org.hamcrest.CoreMatchers.`is` | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.Test | ||
|
||
/** | ||
* | ||
* | ||
* @author Almas Baimagambetov ([email protected]) | ||
*/ | ||
class WaypointMoveComponentTest { | ||
|
||
@Test | ||
fun `Moving via WaypointComponent`() { | ||
val comp = WaypointMoveComponent(100.0, listOf(Point2D(20.0, 50.0), Point2D(40.0, 50.0))) | ||
|
||
val e = Entity() | ||
e.addComponent(comp) | ||
|
||
assertFalse(comp.atDestinationProperty().value) | ||
|
||
comp.onUpdate(5.0) | ||
assertThat(e.position, `is`(Point2D(20.0, 50.0))) | ||
|
||
assertFalse(comp.atDestinationProperty().value) | ||
|
||
comp.onUpdate(5.0) | ||
assertThat(e.position, `is`(Point2D(40.0, 50.0))) | ||
|
||
assertTrue(comp.atDestinationProperty().value) | ||
} | ||
} |