[UPDATED] DataTest
This commit is contained in:
@@ -11,39 +11,48 @@ import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
|
||||
public class DataTest {
|
||||
private Data Data;
|
||||
private Data data;
|
||||
|
||||
@Before
|
||||
public void init(){
|
||||
Data = Data.INSTANCE;
|
||||
data = Data.INSTANCE;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistance(){
|
||||
Data.addDistance(2356.234);
|
||||
data.addDistance(2356.234);
|
||||
double expected = 2356.234;
|
||||
assertEquals(expected, Data.getDistanceTraveled(), 0.01);
|
||||
Data.addDistance(234342.1);
|
||||
assertNotEquals(expected, Data.getDistanceTraveled());
|
||||
assertEquals(expected, data.getDistanceTraveled(), 0.01);
|
||||
data.addDistance(234342.1);
|
||||
assertNotEquals(expected, data.getDistanceTraveled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeWalked(){
|
||||
Data.addTimeWalked(3456);
|
||||
data.addTimeWalked(3456);
|
||||
long expected = 3456;
|
||||
assertEquals(expected, Data.getTimeWalked());
|
||||
Data.addTimeWalked(3445);
|
||||
assertNotEquals(expected, Data.getTimeWalked());
|
||||
assertEquals(expected, data.getTotalTime());
|
||||
data.addTimeWalked(3445);
|
||||
assertNotEquals(expected, data.getTotalTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVisitedLocation(){
|
||||
Location testLocation = new Location("test", "test", "test", "test");
|
||||
Data.visitLocation(testLocation);
|
||||
data.visitLocation(testLocation);
|
||||
int expected = 1;
|
||||
assertEquals(expected, Data.getLocationsVisited());
|
||||
Data.visitLocation(new Location("TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE"));
|
||||
assertNotEquals(expected, Data.getLocationsVisited());
|
||||
assertEquals(expected, data.getLocationsVisited());
|
||||
data.visitLocation(new Location("TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE"));
|
||||
assertNotEquals(expected, data.getLocationsVisited());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZoom(){
|
||||
data.setZoom(234.63);
|
||||
double expected = 234.63;
|
||||
assertEquals(expected, data.getZoom(), 0.01);
|
||||
data.setZoom(342.55);
|
||||
assertNotEquals(expected, data.getZoom());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.a1.nextlocation;
|
||||
|
||||
import com.a1.nextlocation.data.Coupon;
|
||||
import com.a1.nextlocation.data.Data;
|
||||
import com.a1.nextlocation.data.Location;
|
||||
import com.a1.nextlocation.data.Route;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DataTestClass {
|
||||
private Data data;
|
||||
|
||||
@Before
|
||||
public void init(){
|
||||
data = new Data();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSetDistanceTraveled() {
|
||||
data.setDistanceTraveled(100);
|
||||
|
||||
int expected = 100;
|
||||
assertEquals(expected, data.getDistanceTraveled(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetLocationsVisited() {
|
||||
data.setLocationsVisited(16);
|
||||
|
||||
int expected = 16;
|
||||
assertEquals(expected, data.getLocationsVisited());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetTotalTime() {
|
||||
data.setTotalTime(120);
|
||||
|
||||
int expected = 120;
|
||||
assertEquals(expected, data.getTotalTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetCouponList() {
|
||||
List<Coupon> expected = new ArrayList<>();
|
||||
expected.add(new Coupon("CODE1", "REWARD1"));
|
||||
expected.add(new Coupon("CODE2", "REWARD2"));
|
||||
expected.add(new Coupon("CODE3", "REWARD3"));
|
||||
|
||||
data.setCouponList(expected);
|
||||
assertEquals(expected, data.getCouponList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNextLocation() {
|
||||
Location expected = new Location("name1", "cord1", "desc1", null);
|
||||
data.setNextLocation(expected);
|
||||
assertEquals(expected, data.getNextLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLastLocation() {
|
||||
Location expected = new Location("name2", "cord2", "desc2", null);
|
||||
data.setLastLocation(expected);
|
||||
assertEquals(expected, data.getLastLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrentRoute() {
|
||||
Route expected = new Route("testRoute1");
|
||||
data.setCurrentRoute(expected);
|
||||
assertEquals(expected, data.getCurrentRoute());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user