public void AddRoute(Route route) { //Add to route list this.airport.Routes.Add(route); entryManager.InitializeEntryPoint(route.Name); int stationNum = 0; //0 == entry point bool isItarates = true; while (isItarates) { IEnumerable <int> avaliableRoutenNums = route.GetNextAvailableRoute(stationNum); //if there is no such station in the route, stop the loop. if (avaliableRoutenNums.Any(stationNums => stationNums == -1)) { isItarates = false; } //if the IEnumbrable is empty, it means the station does not participate in the route //and won't be manipulate by the builder else if (avaliableRoutenNums.Any()) { LogicStation currentStation = null; //if not the entry point, get the station if (stationNum != 0) { currentStation = stationService.GetStation(stationNum); } foreach (var stationId in avaliableRoutenNums) { //if it is an exist point, dont add any stations and break. if (stationId == 0) { break; } else { LogicStation stationToAdd = stationService.GetStation(stationId); //if in the entry point, add the station to the entryManager. if (stationNum == 0) { entryManager.AddStationToEntry(route.Name, stationToAdd); } //else add the station to the station connections else { currentStation.AddStation(stationToAdd); } } } } //go to the next station stationNum++; } }
public void AddStation() { //Arrange var station1 = new LogicStation(); var station2 = new LogicStation(); //Act station1.AddStation(station2); //Assert Assert.IsTrue(station1.ConnectedStations[0].Equals(station2)); }
public void GetStation() { //Arrange var station1 = new LogicStation(); var station2 = new LogicStation() { StationNumber = 2 }; //Act station1.AddStation(station2); //Assert Assert.IsTrue(station1.GetLogicStationByNumber(2).Equals(station2)); }