You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6 KiB

package seng302.DataInput;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
import seng302.Model.Boat;
import seng302.Model.Mark;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
//import static org.testng.Assert.*;
/**
* Created by cbt24 on 10/05/17.
*/
public class BoatXMLReaderTest {
BoatDataSource boatData;
List<Boat> boats;
List<Mark> marks;
@Before
public void setUp() {
try {
boatData = new BoatXMLReader("mockXML/boatTest.xml");
boats = new ArrayList<>(boatData.getBoats().values());
marks = new ArrayList<>(boatData.getMarkerBoats().values());
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void boatsReadNameFromFile() {
String[] names = {
"Team ORACLE USA","Land Rover BAR","SoftBank Team Japan","Groupama Team France","Artemis Racing","Emirates Team New Zealand"
};
for(int i = 0; i < boats.size(); i++) {
assertEquals(names[i], boats.get(i).getName());
}
}
@Test
public void marksReadNameFromFile() {
String[] names = {
"PRO","PIN","Marker1","WGL","WGR","LGL","LGR","FL","FR"
};
for(int i = 0; i < marks.size(); i++) {
assertEquals(names[i], marks.get(i).getName());
}
}
}