static void Main(string[] args)
        {
            //Generate new route with each run if route doesn't exist so debugging is consistent between users
            string RouteName = "TestRoute1"; //This is what we decide to call a specific route. It is a folder containing track.txt and route.txt

            if (!Directory.Exists(Environment.CurrentDirectory + "/" + RouteName))
            {
                List <Location> destinationsToGenerateRoute = new List <Location>()
                {
                    new Location("2021/03/08 15:30", "Göteborg"),
                    new Location("2021/03/08 15:52", "Alingsås"),
                    new Location("2021/03/08 16:23", "Vårgårda"),
                    new Location("2021/03/08 17:42", "Herrljunga"),
                    new Location("2021/03/08 18:50", "Falköping"),
                    new Location("2021/03/08 19:30", "Stockholm")
                };
                GenerateRoute(RouteName, destinationsToGenerateRoute);
            }
            var      destinations = TrainSchedule.ParseRoute(RouteName); //Here we put the RouteName
            ITrackIO trackIO      = new TrackIO(RouteName);              //Here we put the RouteName

            Train[] trains = Train.Parse("trains.txt");
            trackIO.Parse();

            ITrainSimulation simulation = new TrainSimulation(175, trackIO).AddDestinations(destinations).AddTrain(trains[0]);

            simulation.Start();

            //trains[0] because we only have one train at the moment. But trains.txt can and will contain multiple ones.
        }
Exemple #2
0
        public void OneTrackWithIntermediateStations()
        {
            ITrackIO trackOrm = new TrackIO("Route1");

            trackOrm.Parse(true);

            var result = trackOrm.Track.StationsID.Count;

            Assert.Equal(6, result);
        }
Exemple #3
0
        public void OneTrackWithOnlyEndAndStartStations()
        {
            ITrackIO trackOrm = new TrackIO("Route1");

            trackOrm.Parse(true);

            var First = trackOrm.Track.StationsID[1];
            var Last  = trackOrm.Track.StationsID[trackOrm.Track.StationsID.Count - 1];

            Station[] result = { First, Last };

            Assert.Equal(2, result.Length);
        }