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);
        }
Пример #2
0
        public List<String> readAPI()
        {
            List<FilmLocations> films;
            List<String> filmNames = new List<string>();
            //FilmLocations filmLoc = new filmTitle;
            LocnXMLReader xmlObject = new LocnXMLReader();
            xmlObject.setSource("https://nycopendata.socrata.com/download/qb3k-n8mm/application/xml");
            films = xmlObject.readAllFilms();

            foreach (FilmLocations f in films)
            {
                filmNames.Add(f.filmTitle);
            }

            return filmNames;
        }