public void ThrowErrorOnInvalidStationInputNotOnList() { //Arrange var invalidStation = new Station(){Name = "Test", Code = "Test"}; //Act var nationalRailQuery = new NationalRailQuery(invalidStation, null); }
public void Setup() { NationalRailQuery.BuildStationList(); IEnumerable<Station> stationQuery = from station in NationalRailQuery.Stations where station.Code == StoneleighRailCode select station; _stoneleigh = stationQuery.First(); if (_stoneleigh.Code != StoneleighRailCode) throw new ArgumentException("Invaild data loaded in test setup"); }
public void ReadStationXmlandHaveStoneleighStationPresent() { //Arrange NationalRailQuery.BuildStationList(); IEnumerable<Station> stationQuery = from station in NationalRailQuery.Stations where station.Code == StoneleighRailCode select station; //Act _stoneleigh = stationQuery.First(); //Assert Assert.IsTrue(NationalRailQuery.Stations.Count == 1, "No Stations have been loaded"); Assert.IsTrue(_stoneleigh.Code == StoneleighRailCode, "Invalid station loaded in unit test data"); }
/// <summary> /// Initializes a new instance of the <see cref="NationalRailQuery"/> class. /// </summary> /// <param name="fromStation">From station.</param> /// <param name="toStation">To station.</param> public NationalRailQuery(Station fromStation, Station toStation) :this() { if(fromStation == null && toStation == null) throw new ArgumentException(Resource.InvalidStationCode); //Validation to occur in implementing class as this is provider specific FromStation = fromStation; ToStation = toStation; //Check Station Exists ValidateStations(); //Compile Uri for Station Query _nationalRailQueryUri = CompileUri(); }
string CompileUri() { //Check station properties if they have not been set if(FromStation == null) FromStation = new Station(); if(ToStation == null) ToStation = new Station(); string uri = string.Format("{0}{1}&{2}&{3}&{4}", NetworkRailBaseUri, string.Format(DepartingParameter, false), string.Format(TrainsFromParameter, FromStation.Code), string.Format(TrainsToParameter, ToStation.Code), string.Format(ServiceIdParameter, string.Empty)); return uri; }