public void readAllFilmsTest() { LocnXMLReader target = new LocnXMLReader(); // Context db = new Context(); // db.Database.Delete(); // db.Database.Create(); target.setSource("https://nycopendata.socrata.com/download/qb3k-n8mm/application/xml"); List<FilmLocations> filmList = target.readAllFilms(); LocationFinder locFinder = new LocationFinder(); bool film25thHourFound = false; bool filmAThousandClownsFound = false; foreach (String film in locFinder.getAllFilmNames()) { if (film == "25th Hour") film25thHourFound = true; else if (film == "A Thousand Clowns") filmAThousandClownsFound = true; } Assert.AreEqual(film25thHourFound, true); Assert.AreEqual(filmAThousandClownsFound, true); LocationListUI locList = locFinder.getLocationsForFilm("25th Hour"); bool foundLoc1 = false; bool foundLoc2 = false; foreach (String locText in locList.locations) { if (locText == "World Trade Center, Lower Manhattan") foundLoc1 = true; else if (locText == "Carl Schurz Park, Upper East Side, Manhattan") foundLoc2 = true; else Assert.Fail("Unexpected location in film 25th Hour " + locText); } Assert.AreEqual(foundLoc1, true); Assert.AreEqual(foundLoc2, true); locList = locFinder.getLocationsForFilm("A Thousand Clowns"); foundLoc1 = false; foreach (String locText in locList.locations) { if (locText == "Statue of Liberty, Liberty Island, New York Harbor") foundLoc1 = true; else Assert.Fail("Unexpected location in film A Thousand Clowns " + locText); } Assert.AreEqual(foundLoc1, true); }
public void getLocationsForFilmTest() { LocationFinder target = new LocationFinder(); String filmName; LocationListUI expected, actual; filmName = "12 Angry Men"; expected = new LocationListUI(); expected.filmName = filmName; expected.locations = new List<String>(); expected.locations.Add ("New York County Courthouse<br>40 Foley Square<br>Lower Manhattan"); actual = target.getLocationsForFilm(filmName); Assert.AreEqual(expected, actual); filmName = "15 Minutes"; expected = new LocationListUI(); expected.filmName = filmName; expected.locations = new List<String>(); expected.locations.Add("E. 60-66th St.and Madison Ave.<br>Upper East Side<br>Manhattan"); expected.locations.Add("Carl Schurz Park<br>Upper East Side<br>Manhattan"); actual = target.getLocationsForFilm(filmName); Assert.AreEqual(expected, actual); }