Skip to content

Commit

Permalink
Added a TrackTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andra Bisca committed Oct 23, 2018
1 parent 21fa8c2 commit bd4f9fb
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
Expand Up @@ -34,7 +34,7 @@ public class Track {
public Track(String uid, String creatorName, Bitmap image, String name, LatLng[] path, TrackProperties properties) {

Required.nonNull(uid, "User ID must be non-null");
Required.nonNull(image, "Image must be non-null");
//Required.nonNull(image, "Image must be non-null");
Required.nonNull(path, "Path must be non-null");
Required.nonNull(properties, "Properties must be non null");
Required.nonNull(creatorName, "Name of the creator of track must be non-null");
Expand Down
61 changes: 61 additions & 0 deletions app/src/test/java/ch/epfl/sweng/runpharaa/TrackTest.java
@@ -0,0 +1,61 @@
package ch.epfl.sweng.runpharaa;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.google.android.gms.maps.model.LatLng;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.util.HashSet;
import java.util.Set;

import ch.epfl.sweng.runpharaa.tracks.Track;
import ch.epfl.sweng.runpharaa.tracks.TrackProperties;
import ch.epfl.sweng.runpharaa.tracks.TrackType;

public class TrackTest {

@Rule
public final ExpectedException exception = ExpectedException.none();
private Bitmap b;
private Set<TrackType> types;
private TrackProperties p;
private LatLng coord0;
private LatLng coord1;
private LatLng[] path;
private Track legalTestTrack;

@Before
public void init() {
b = Bitmap.createBitmap(200, 100, Bitmap.Config.ARGB_8888);
types = new HashSet<>();
types.add(TrackType.FOREST);
p = new TrackProperties(100, 10, 1, 1, types);

coord0 = new LatLng(46.518577, 6.563165);
coord1 = new LatLng(46.522735, 6.579772);

path = new LatLng[]{coord0, coord1};

legalTestTrack = new Track("7864", "Bob", b, "test", path , p);
}

@Test
public void PathWithLessThan2PointsThrowsException() {

LatLng[] path = {coord0};

exception.expect(IllegalArgumentException.class);
new Track("8498", "Bob", b, "test", path, p);

}

@Test
public void startingPositionIsCorrect(){
assert legalTestTrack.getStartingPoint().equals(coord0);
}
}

0 comments on commit bd4f9fb

Please sign in to comment.