コード例 #1
0
        public void CreateStationForecastFromRealTimeInfo_()
        {
            UnitTestStationInformationLoader loader = new UnitTestStationInformationLoader();

            loader.AddStations(new Station()
            {
                Abbreviation = "STS", Name = "St. Stephen's Green", IsInUse = true
            });
            loader.AddStations(new Station()
            {
                Abbreviation = "PAR", Name = "Parnell", IsInUse = true
            });
            loader.AddStations(new Station()
            {
                Abbreviation = "SAN", Name = "Sandyford", IsInUse = true
            });

            Stations stations = new Stations(loader);

            RealTimeInfo realTimeInfo = CreateRealTimeInfoFromXml("<stopInfo created=\"2019-12-31T12:00:00\" stop=\"St. Stephen's Green\" stopAbv=\"STS\"><message>Green Line services operating normally</message><direction name=\"Inbound\"><tram destination=\"Parnell\" dueMins=\"1\" /></direction><direction name=\"Outbound\"><tram dueMins=\"6\" destination=\"Sandyford\" /></direction></stopInfo>");

            StationForecast forecast = StationForecast.CreateStationForecastFromRealTimeInfo(realTimeInfo, stations);

            Assert.Equal(realTimeInfo.Stop, forecast.Station.Name);
            Assert.Single(forecast.InboundTrams);
            Assert.Single(forecast.OutboundTrams);
        }
コード例 #2
0
        public void GetAllStations_ReturnOnlyThoseInUse_OneStationInUse_TwoStationsNotInUse_ReturnsOneStation()
        {
            UnitTestStationInformationLoader loader = new UnitTestStationInformationLoader();

            loader.AddStations(
                new Station()
            {
                Abbreviation = "STS", IsInUse = false
            },
                new Station()
            {
                Abbreviation = "SAN", IsInUse = true
            },
                new Station()
            {
                Abbreviation = "HAR", IsInUse = false
            });

            Stations stations = new Stations(loader);

            var result = stations.GetAllStations();

            Assert.IsType <List <Station> >(result);
            Assert.Single(result);
        }
コード例 #3
0
        public void GetStationFromName_LowercaseQueryStationExists_ReturnsStation()
        {
            UnitTestStationInformationLoader loader = new UnitTestStationInformationLoader();

            Station station = new Station {
                Name = "St. Stephen's Green", Abbreviation = "STS"
            };

            loader.AddStations(station);

            Stations stations = new Stations(loader);

            Assert.Equal(station, stations.GetStationFromName(station.Name.ToLowerInvariant()));
        }
コード例 #4
0
        public void GetAllStations_DontReturnOnlyThoseInUse_OneStationNotInUse_ReturnsEmptyList()
        {
            UnitTestStationInformationLoader loader = new UnitTestStationInformationLoader();

            loader.AddStations(new Station()
            {
                Abbreviation = "STS", IsInUse = false
            });

            Stations stations = new Stations(loader);

            var result = stations.GetAllStations(returnOnlyStationsInUse: false);

            Assert.IsType <List <Station> >(result);
            Assert.Single(result);
        }
コード例 #5
0
        public void GetAllStations_OneStation_ReturnsListWithOneItem()
        {
            UnitTestStationInformationLoader loader = new UnitTestStationInformationLoader();

            loader.AddStations(new Station()
            {
                Abbreviation = "STS", IsInUse = true
            });

            Stations stations = new Stations(loader);

            var result = stations.GetAllStations();

            Assert.IsType <List <Station> >(result);
            Assert.Single(result);
        }
コード例 #6
0
        public void GetStationFromName_MoreThanOneStationAvailable_ReturnsCorrectStation()
        {
            UnitTestStationInformationLoader loader = new UnitTestStationInformationLoader();

            Station alternativeStation = new Station {
                Name = "Harcourt", Abbreviation = "HAR"
            };
            Station stationToQuery = new Station {
                Name = "St. Stephen's Green", Abbreviation = "STS"
            };

            loader.AddStations(alternativeStation, stationToQuery);

            Stations stations = new Stations(loader);

            Assert.Equal(stationToQuery, stations.GetStationFromName(stationToQuery.Name));
        }