public void PushPlane(Plane plane) { Task.Run(() => { LogicStation.GetBestStation(EntryManager.GetEntryStations(plane.Route.Name)).EnterStation(plane); }); }
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)); }
/// <summary> /// Returns a station without planes(waiting line and current plane) /// </summary> /// <param name="station"></param> /// <returns></returns> private LogicStation RestoreStation(Station station) { LogicStation logicStation = new LogicStation() { Id = station.Id, StationName = station.StationName, StationNumber = station.StationNumber, WaitingTime = station.WaitingTime, }; return(logicStation); }
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)); }
public void EnterStation_2Planes() { //Arrange var s1 = new LogicStation() { WaitingTime = TimeSpan.FromSeconds(4), StationNumber = 1 }; var plane1 = new Plane() { Route = new MockRoute(), FlightNumber = "0" }; var plane2 = new Plane() { Route = new MockRoute(), FlightNumber = "1" }; //Act s1.EnterStation(plane1); Thread.Sleep(50); s1.EnterStation(plane2); Thread.Sleep(50); //Assert testStationService.IsCurrentPlane(s1, "0"); testStationService.IsExistInWaitingLine(s1, "1"); Thread.Sleep(TimeSpan.FromSeconds(4.1)); testStationService.IsCurrentPlane(s1, "1"); testStationService.IsWaitingLineEmpty(s1); Thread.Sleep(TimeSpan.FromSeconds(4.1)); Assert.IsFalse(testStationService.HasCurrentPlane(s1)); }
public void CreateStation(string stationName, TimeSpan timeSpan) { stationCount++; if (stationCount == 0) { throw new ArgumentException("Station number cannot be 0"); } if (stations.Any(s => s.StationNumber == stationCount)) { throw new ArgumentException("Station number must be unique"); } LogicStation station = new LogicStation() { StationNumber = stationCount, StationName = stationName, WaitingTime = timeSpan, }; AddStation(station); }
public void EnterStation_1Plane() { //Arrange var station1 = new LogicStation { WaitingTime = TimeSpan.FromSeconds(2) }; var plane = new Plane() { Route = new MockRoute() }; //Act station1.EnterStation(plane); //Assert Thread.Sleep(10); Assert.IsTrue(station1.CurrentPlane.Equals(plane)); Thread.Sleep(TimeSpan.FromSeconds(2.01)); Assert.IsTrue(station1.CurrentPlane == null); }
public void InitializeLogicStation() { var station = new LogicStation(); }
internal void AddStationToEntry(string entryName, LogicStation station) { EntryPoints[entryName].Add(station); }
private void AddStation(LogicStation station) { station.ChangeInState += this.changeInStateEvent.RaiseChangeInStateEvent; this.stations.Add(station); }