public void WhenShortestPathIsCalledWithGivenParameters_ThenReturnCorrectList() { // Arrange List <BusRouteEntity> busRoutes = new List <BusRouteEntity>(); BusStationFactory busStationFactory = new BusStationFactory(); CoordinatesFactory coordinatesFactory = new CoordinatesFactory(); BusRouteFactory busRouteFactory = new BusRouteFactory(); List <BusStationEntity> busStationList = new List <BusStationEntity> { busStationFactory.GetBusEntity(Guid.Empty, "Station_One", coordinatesFactory.GetCoordinatesEntity(3.452, 3.567), null, DateTime.Now, DateTime.Now), busStationFactory.GetBusEntity(Guid.Empty, "Station_Two", coordinatesFactory.GetCoordinatesEntity(4.452, 4.567), null, DateTime.Now, DateTime.Now), busStationFactory.GetBusEntity(Guid.Empty, "Station_Three", coordinatesFactory.GetCoordinatesEntity(5.452, 5.567), null, DateTime.Now, DateTime.Now) }; BusRouteEntity firstBusRouteEntity = busRouteFactory.GetBusRouteEntity(Guid.Empty, "30", busStationList, DateTime.Now, DateTime.Now); busRoutes.Add(firstBusRouteEntity); // Act List <(string, string, CoordinatesEntity, string, CoordinatesEntity)> result = BusStationExtensions.ShortestPath(busRoutes, "Station_One", "Station_Three"); List <(string, string, CoordinatesEntity, string, CoordinatesEntity)> realResult = new List <(string, string, CoordinatesEntity, string, CoordinatesEntity)>(); CoordinatesEntity firstStationStartCoordinates = coordinatesFactory.GetCoordinatesEntity(3.452, 3.567); CoordinatesEntity firstStationEndCoordinates = coordinatesFactory.GetCoordinatesEntity(5.452, 5.567); (string, string, CoordinatesEntity, string, CoordinatesEntity)realResultTupleOne = ("30", "Station_One", firstStationStartCoordinates, "Station_Three", firstStationEndCoordinates); realResult.Add(realResultTupleOne); // Assert bool flag = true; for (int i = 0; i < result.Count; i++) { if (!result[i].Item1.Equals(realResult[i].Item1) || !result[i].Item2.Equals(realResult[i].Item2) || !result[i].Item3.Equals(realResult[i].Item3) || !result[i].Item4.Equals(realResult[i].Item4) || !result[i].Item5.Equals(realResult[i].Item5)) { flag = false; } } if (result.Count != realResult.Count) { flag = false; } Assert.IsTrue(flag); }
public void WhenShortestPathIsCalledWithNoPossiblePath_ThenReturnNull() { // Arrange List <BusRouteEntity> busRoutes = new List <BusRouteEntity>(); BusStationFactory busStationFactory = new BusStationFactory(); CoordinatesFactory coordinatesFactory = new CoordinatesFactory(); BusRouteFactory busRouteFactory = new BusRouteFactory(); List <BusStationEntity> busStationList = new List <BusStationEntity> { busStationFactory.GetBusEntity(Guid.Empty, "Station_One", coordinatesFactory.GetCoordinatesEntity(3.452, 3.567), null, DateTime.Now, DateTime.Now), busStationFactory.GetBusEntity(Guid.Empty, "Station_Two", coordinatesFactory.GetCoordinatesEntity(4.452, 4.567), null, DateTime.Now, DateTime.Now), busStationFactory.GetBusEntity(Guid.Empty, "Station_Three", coordinatesFactory.GetCoordinatesEntity(5.452, 5.567), null, DateTime.Now, DateTime.Now) }; BusRouteEntity firstBusRouteEntity = busRouteFactory.GetBusRouteEntity(Guid.Empty, "30", busStationList, DateTime.Now, DateTime.Now); busRoutes.Add(firstBusRouteEntity); // Act List <(string, string, CoordinatesEntity, string, CoordinatesEntity)> result = BusStationExtensions.ShortestPath(busRoutes, "Station_One", "Station_Four"); // Assert Assert.IsNull(result); }