Exemplo n.º 1
0
 public ActionResult Search(string searchType, string searchTerm)
 {
     if (searchType.Equals("forCity"))
     {
         Dictionary <string, object> model = new Dictionary <string, object>();
         List <City> allCities             = City.FindByName(searchTerm);
         if (allCities.Count > 0)
         {
             Country selectedCountry = Country.Find(allCities[0].GetCountryId());
             model.Add("selectedCountry", selectedCountry);
         }
         else
         {
             Country selectedCountry = new Country("");
             model.Add("selectedCountry", selectedCountry);
         }
         model.Add("allCities", allCities);
         return(View("../Cities/Index", model));
     }
     else if (searchType.Equals("forAttraction"))
     {
         return(View("../Attractions/Index", Attraction.FindByName(searchTerm)));
     }
     else
     {
         return(View("../Activities/Index", Activity.FindByActivityName(searchTerm)));
     }
 }
        public void FindByName_FindAttractionsInDatabase_AttractionList()
        {
            //Arrange
            Attraction testAttraction = new Attraction("testName", 1, "testDescription");

            testAttraction.Save();
            List <Attraction> testList = new List <Attraction> {
                testAttraction
            };

            //Act
            List <Attraction> resultList = Attraction.FindByName(testAttraction.GetName());

            //Assert
            CollectionAssert.AreEqual(testList, resultList);
        }