Fix last time issue with nodes

This commit is contained in:
Ludovic Goix 2020-07-23 23:12:01 -04:00
parent e6e80dec5f
commit c56f14a259
3 changed files with 51 additions and 9 deletions

View file

@ -14,5 +14,10 @@ class PositionTest {
Assert.assertEquals(Position.degD(Position.degI(-89.0)), -89.0, 0.01)
}
@Test
fun givenPositionCreatedWithoutTime_thenTimeIsSet() {
val position = Position(37.1, 121.1, 35)
Assert.assertTrue(position.time != 0)
}
}

View file

@ -0,0 +1,31 @@
package com.geeksville.mesh.service
import com.geeksville.mesh.MeshUser
import com.geeksville.mesh.NodeInfo
import com.geeksville.mesh.Position
import org.junit.Assert
import org.junit.Test
class MeshServiceTest {
val nodeInfo = NodeInfo(4, MeshUser("+one", "User One", "U1"), Position(37.1, 121.1, 35, 10))
@Test
fun givenNodeInfo_whenUpdatingWithNewTime_thenPositionTimeIsUpdated() {
val newerTime = 20
updateNodeInfoTime(nodeInfo, newerTime)
Assert.assertEquals(newerTime, nodeInfo.position?.time)
}
@Test
fun givenNodeInfo_whenUpdatingWithOldTime_thenPositionTimeIsNotUpdated() {
val olderTime = 5
val timeBeforeTryingToUpdate = nodeInfo.position?.time
updateNodeInfoTime(nodeInfo, olderTime)
Assert.assertEquals(timeBeforeTryingToUpdate, nodeInfo.position?.time)
}
}