public ActionResult Search(string code) { if (!string.IsNullOrWhiteSpace(code)) { AirportDto airportDto = m_AirportControllerHandler.GetAirportInformationFromCouchbaseByAirportCode(code); if (airportDto.IsNullOrDefault()) { airportDto = m_AirportControllerHandler.GetAirportInformationByAirportCode(code); m_AirportControllerHandler.AddAirportInformationToCouchbase(airportDto); } if (!airportDto.IsNullOrDefault()) { AirportViewModel airportViewModel = new AirportViewModel { AirportCode = airportDto.AirportCode, CityOrAirportName = airportDto.CityOrAirportName, Country = airportDto.Country, CountryCode = airportDto.CountryCode, LatitudeDegree = airportDto.LatitudeDegree, LongitudeDegree = airportDto.LongitudeDegree }; return View(airportViewModel); } } return null; }
public void SearchWhenGetFromCouchbase() { Init(); string code = "AMS"; AirportDto airportDto = new AirportDto { AirportCode = "AMS", CityOrAirportName = "Amsterdam", Country = "Netherlands", CountryCode = "461", LatitudeDegree = "52", LongitudeDegree = "4" }; m_AirportControllerHandlerMock.GetAirportInformationFromCouchbaseByAirportCode(code).Returns(airportDto); AirportViewModel airportViewModel = new AirportViewModel { AirportCode = airportDto.AirportCode, CityOrAirportName = airportDto.CityOrAirportName, Country = airportDto.Country, CountryCode = airportDto.CountryCode, LatitudeDegree = airportDto.LatitudeDegree, LongitudeDegree = airportDto.LongitudeDegree }; AirportController airportController = new AirportController(m_AirportControllerHandlerMock); var result = airportController.Search(code) as ActionResult; Assert.IsNotNull(airportViewModel); Assert.IsNotNull(result); }