public void GetValidStationLinks_IsEmptyColor_ShouldBeAllLinks(string trainColor) { //Arrange _stationConfigurationProviderMock.GetStations().Returns(_stationsRepository.Values.ToList()); _stationConfigurationProviderMock.GetStationLinks().Returns(_linksRepository[string.Empty]); IStationService stationService = new StationService(_stationConfigurationProviderMock); //Act List <StationLink> links = stationService.GetValidStationLinks(trainColor); //Assert Assert.Equal(_linksRepository[string.Empty].Count, links.Count); }
public List <StationLink> GetValidStationLinks(string trainColor) { List <StationLink> stationLinks = _stationConfigurationProvider.GetStationLinks(); List <Station> invalidStations = _stationConfigurationProvider.GetStations().Where(s => !s.IsValidStation(trainColor)).ToList(); while (stationLinks.Any(sl => !sl.IsValidLink(trainColor))) { foreach (Station invalidStation in invalidStations) { ReplaceInvalidStationLinks(stationLinks, invalidStation); } } return(stationLinks); }