Merge branch 'Tests' of https://github.com/SemvdH/Next-Location into Tests
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package com.a1.nextlocation;
|
||||
|
||||
import com.a1.nextlocation.json.DirectionsResult;
|
||||
import com.a1.nextlocation.json.DirectionsStep;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DirectionsResultTest {
|
||||
private DirectionsResult directionsResult;
|
||||
|
||||
@Before
|
||||
public void init(){
|
||||
directionsResult = new DirectionsResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistance(){
|
||||
directionsResult.setDistance(45.32);
|
||||
double expected = 45.32;
|
||||
|
||||
assertEquals(expected, directionsResult.getDistance(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuration(){
|
||||
directionsResult.setDuration(95.123);
|
||||
double expected = 95.123;
|
||||
|
||||
assertEquals(expected, directionsResult.getDuration(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSteps(){
|
||||
List<DirectionsStep> expected = new ArrayList<>();
|
||||
directionsResult.addStep(new DirectionsStep());
|
||||
directionsResult.addStep(new DirectionsStep());
|
||||
directionsResult.addStep(new DirectionsStep());
|
||||
directionsResult.setSteps(expected);
|
||||
|
||||
assertEquals(expected, directionsResult.getSteps());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.a1.nextlocation;
|
||||
|
||||
import com.a1.nextlocation.json.DirectionsStep;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.osmdroid.util.GeoPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DirectionsStepTest {
|
||||
private DirectionsStep directionsStep;
|
||||
@Before
|
||||
public void init(){
|
||||
directionsStep = new DirectionsStep();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistance(){
|
||||
directionsStep.setDistance(432.56);
|
||||
double expected = 432.56;
|
||||
assertEquals(expected, directionsStep.getDistance(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuration(){
|
||||
directionsStep.setDuration(531.89);
|
||||
double expected = 531.89;
|
||||
assertEquals(expected, directionsStep.getDuration(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstuction(){
|
||||
directionsStep.setInstruction("TESTINGINSTUCTION");
|
||||
String expected = "TESTINGINSTUCTION";
|
||||
assertEquals(expected, directionsStep.getInstruction());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName(){
|
||||
directionsStep.setName("TESTINGNAME");
|
||||
String expected = "TESTINGNAME";
|
||||
assertEquals(expected, directionsStep.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWay_Points(){
|
||||
ArrayList<Integer> expected = new ArrayList<>();
|
||||
expected.add(56);
|
||||
expected.add(1123);
|
||||
expected.add(23);
|
||||
expected.add(73);
|
||||
directionsStep.setWay_points(expected);
|
||||
|
||||
assertEquals(expected, directionsStep.getWay_points());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWayPoints(){
|
||||
GeoPoint[] expected = {new GeoPoint(5.1658, 4.163), new GeoPoint(2.0896, 7.158),
|
||||
new GeoPoint(4.0168, 6.1450), new GeoPoint(7.1498, 9.1586), };
|
||||
directionsStep.setWaypoints(expected);
|
||||
|
||||
assertEquals(expected, directionsStep.getWaypoints());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user