package model;/**
 * Created by Gondr on 4/04/2017.
 */

import static org.junit.Assert.*;

import javafx.collections.FXCollections;
import org.junit.Test;

public class DataManagerTest {

    @Test
    public void addRide(){
        DataManager dataManager = new DataManager();
        Ride ride = new Ride("Nissan March", "Blue", "HB9999", 2008, 4);
        dataManager.addRides(ride);
        assertTrue(dataManager.getRides().get(0) == ride);

        dataManager.removeRide(0);
        assertTrue(dataManager.getRides().size() == 0);

        dataManager.addRides(ride);
        dataManager.removeRide(ride);
        assertTrue(dataManager.getRides().size() == 0);
    }

    @Test
    public void addStop(){
        DataManager dataManager = new DataManager();
        Stop stop1 = new Stop("Stop 1");
        Stop stop2 = new Stop("Stop 2");
        Stop stop3 = new Stop("Stop 1");
        dataManager.addStop(stop1);
        assertTrue(dataManager.getStops().size() == 1);
        assertTrue(!dataManager.addStop(stop1));
        assertTrue(!dataManager.addStop(stop3));
        assertTrue(dataManager.addStop(stop2));
        assertTrue(dataManager.getStops().size() == 2);
    }

    @Test
    public void addRoute(){
        DataManager dataManager = new DataManager();
        Stop stop1 = new Stop("Stop 1");
        Stop stop2 = new Stop("Stop 2");
        Stop stop3 = new Stop("Stop 3");
        Stop stop4 = new Stop("Stop 4");
        Stop stop5 = new Stop("Stop 5");
        Stop[] stops = {stop1, stop2, stop3, stop4, stop5};
        Route route = new Route("Route1", FXCollections.observableArrayList(stops));
        dataManager.addRoute(route);
        assertTrue(dataManager.getRoutes().size() == 1);
        //does not add duplicate routes
        assertTrue(!dataManager.addRoute(route));
        assertTrue(dataManager.getRoutes().size() == 1);
        Route route2 = new Route("Route 2", FXCollections.observableArrayList(stops));
        assertTrue(!dataManager.addRoute(route2));
        assertTrue(dataManager.getRoutes().size() == 1);
        //can acutally add another route
        Stop[] stops1 = {stop1, stop2};
        Route route3 = new Route("Route 3", FXCollections.observableArrayList(stops1));
        assertTrue(dataManager.addRoute(route3));
        assertTrue(dataManager.getRoutes().size() == 2);
    }

}