rename staticdata to data

This commit is contained in:
Sem van der Hoeven
2021-01-06 17:16:19 +01:00
parent ce264d78bc
commit 91670fb6f3
7 changed files with 98 additions and 186 deletions

View File

@@ -0,0 +1,49 @@
package com.a1.nextlocation;
import com.a1.nextlocation.data.Location;
import com.a1.nextlocation.data.Data;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
public class DataTest {
private Data Data;
@Before
public void init(){
Data = Data.INSTANCE;
}
@Test
public void testDistance(){
Data.addDistance(2356.234);
double expected = 2356.234;
assertEquals(expected, Data.getDistanceTraveled(), 0.01);
Data.addDistance(234342.1);
assertNotEquals(expected, Data.getDistanceTraveled());
}
@Test
public void testTimeWalked(){
Data.addTimeWalked(3456);
long expected = 3456;
assertEquals(expected, Data.getTimeWalked());
Data.addTimeWalked(3445);
assertNotEquals(expected, Data.getTimeWalked());
}
@Test
public void testVisitedLocation(){
Location testLocation = new Location("test", "test", "test", "test");
Data.visitLocation(testLocation);
int expected = 1;
assertEquals(expected, Data.getLocationsVisited());
Data.visitLocation(new Location("TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE"));
assertNotEquals(expected, Data.getLocationsVisited());
}
}

View File

@@ -1,49 +0,0 @@
package com.a1.nextlocation;
import com.a1.nextlocation.data.Location;
import com.a1.nextlocation.data.StaticData;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
public class StaticDataTest {
private StaticData staticData;
@Before
public void init(){
staticData = StaticData.INSTANCE;
}
@Test
public void testDistance(){
staticData.addDistance(2356.234);
double expected = 2356.234;
assertEquals(expected, staticData.getDistanceTraveled(), 0.01);
staticData.addDistance(234342.1);
assertNotEquals(expected, staticData.getDistanceTraveled());
}
@Test
public void testTimeWalked(){
staticData.addTimeWalked(3456);
long expected = 3456;
assertEquals(expected, staticData.getTimeWalked());
staticData.addTimeWalked(3445);
assertNotEquals(expected, staticData.getTimeWalked());
}
@Test
public void testVisitedLocation(){
Location testLocation = new Location("test", "test", "test", "test");
staticData.visitLocation(testLocation);
int expected = 1;
assertEquals(expected, staticData.getLocationsVisited());
staticData.visitLocation(new Location("TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE"));
assertNotEquals(expected, staticData.getLocationsVisited());
}
}