This commit is contained in:
Sem van der Hoeven
2021-01-14 11:13:23 +01:00
parent eae347844a
commit 7c0b57aa01
2 changed files with 37 additions and 7 deletions

View File

@@ -20,29 +20,53 @@ public class DataTest {
@Test
public void testDistance(){
try {
data.addDistance(2356.234);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
double expected = 2356.234;
assertEquals(expected, data.getDistanceTraveled(), 0.01);
data.addDistance(234342.1);
try {
data.addDistance(2356.234);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNotEquals(expected, data.getDistanceTraveled());
}
@Test
public void testTimeWalked(){
try {
data.addTimeWalked(3456);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
long expected = 3456;
assertEquals(expected, data.getTotalTime());
data.addTimeWalked(3445);
try {
data.addTimeWalked(3456);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNotEquals(expected, data.getTotalTime());
}
@Test
public void testVisitedLocation(){
Location testLocation = new Location("test", "test", "test", "test");
try {
data.visitLocation(testLocation);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
int expected = 1;
assertEquals(expected, data.getLocationsVisited());
try {
data.visitLocation(new Location("TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE"));
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNotEquals(expected, data.getLocationsVisited());
}

View File

@@ -1,5 +1,7 @@
package com.a1.nextlocation;
import android.util.Log;
import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.data.RouteHandler;
@@ -50,7 +52,11 @@ public class RouteHandlerTest {
assertEquals(expected, routeHandler.isFollowingRoute());
assertEquals(testRoute, routeHandler.getCurrentRoute());
try {
routeHandler.finishRoute();
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNull(routeHandler.getCurrentRoute());
routeHandler.followRoute(new Route("FALSEROUTENAME"));