Elevation gain: make it optional as Float.

So if no sensor data is provided, it is not stored in the database and not exported.
This commit is contained in:
Dennis Guse
2020-09-05 11:45:54 +02:00
parent e0d1ad4b52
commit 6845ce4984
4 changed files with 38 additions and 9 deletions
@@ -24,6 +24,9 @@ public class ElevationSumManagerTest {
@Test
public void getElevationGainLoss_downhill() {
// given
elevationSumManager.setConnected(true);
// then
addSensorValue(elevationSumManager, new float[]{1015f, 1015.01f, 1015.02f, 1015.03f, 1015.04f, 1015.05f, 1015.06f, 1015.07f, 1015.08f, 1015.09f, 1015.10f, 1015.11f, 1015.12f, 1015.13f, 1015.14f, 1015.15f});
@@ -31,4 +34,17 @@ public class ElevationSumManagerTest {
Assert.assertEquals(0f, elevationSumManager.getElevationGain_m(), 0.01);
Assert.assertEquals(-48.0, elevationSumManager.getElevationLoss_m(), 0.01);
}
@Test
public void sensorUnavailable() {
// given
elevationSumManager.setConnected(false);
// then
elevationSumManager.onSensorValueChanged(999f);
// then
Assert.assertNull(elevationSumManager.getElevationGain_m());
Assert.assertNull(elevationSumManager.getElevationLoss_m());
}
}