-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add initial unit tests * Fix for nested variable naming * version
- Loading branch information
Showing
5 changed files
with
125 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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,98 @@ | ||
package tests | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.AfterAll | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.fail | ||
|
||
import org.team5499.dashboard.Dashboard | ||
import org.team5499.dashboard.DashboardVar | ||
import org.team5499.dashboard.DashboardException | ||
|
||
class NestedVariableTest { | ||
|
||
companion object { | ||
@BeforeAll | ||
@JvmStatic | ||
fun initDashboard() { | ||
Dashboard.start(this, "playgroundConf.json") | ||
Constants.initConstants() | ||
} | ||
|
||
@AfterAll | ||
@JvmStatic | ||
fun tearDownDashboard() { | ||
Dashboard.stop() | ||
} | ||
} | ||
|
||
@Test | ||
fun checkForOuterVar() { | ||
try { | ||
assertEquals(Dashboard.getDouble("Constants.PROP"), 1.0) | ||
} catch (de: DashboardException) { | ||
fail<Any>("Constants.PROP not found") | ||
} | ||
} | ||
|
||
@Test | ||
fun checkForFirstVar() { | ||
try { | ||
assertEquals(Dashboard.getDouble("Constants.First.PROP"), 2.0) | ||
} catch (de: DashboardException) { | ||
fail<Any>("Constants.First.PROP not found") | ||
} | ||
} | ||
|
||
@Test | ||
fun checkForSecondVar() { | ||
try { | ||
assertEquals(Dashboard.getDouble("Constants.Second.PROP"), 3.0) | ||
} catch (de: DashboardException) { | ||
fail<Any>("Constants.Second.PROP not found") | ||
} | ||
} | ||
|
||
@Test | ||
fun checkForOuterNestVar() { | ||
try { | ||
assertEquals(Dashboard.getDouble("Constants.Nest.PROP"), 4.0) | ||
} catch (de: DashboardException) { | ||
fail<Any>("Constants.Nest.PROP not found") | ||
} | ||
} | ||
|
||
@Test | ||
fun checkForInnerNestVar() { | ||
try { | ||
assertEquals(Dashboard.getDouble("Constants.Nest.Inner.PROP"), 5.0) | ||
} catch (de: DashboardException) { | ||
fail<Any>("Constants.Nest.Inner.PROP not found") | ||
} | ||
} | ||
} | ||
|
||
object Constants { | ||
|
||
public fun initConstants() { | ||
DashboardVar.initClassProps(Constants::class) | ||
} | ||
|
||
public var PROP by DashboardVar(1.0) | ||
|
||
object First { | ||
public var PROP by DashboardVar(2.0) | ||
} | ||
|
||
object Second { | ||
public var PROP by DashboardVar(3.0) | ||
} | ||
|
||
object Nest { | ||
public var PROP by DashboardVar(4.0) | ||
object Inner { | ||
public var PROP by DashboardVar(5.0) | ||
} | ||
} | ||
} |