Example #1
0
 public WebDataService(string key)
 {
     //default to ComicVine
     this.connection = new ComicVineWebConnection();
     this.reader     = new ComicVineXMLReader();
     this.urlBuilder = new ComicVineURLBuilder(key, format);
 }
 public WebDataService(string key)
 {
     //default to ComicVine
     this.connection = new ComicVineWebConnection();
     this.reader = new ComicVineXMLReader();
     this.urlBuilder = new ComicVineURLBuilder(key, format);
 }
        public void GenerateDiscoverTVURLWithGenresSortByPopularityDescPage3()
        {
            newManufacturer = new URLManufacturer();
            urlBuilder = new DiscoverTVURLBuilder(3);

            newManufacturer.Construct(urlBuilder);
            string[] myGenres =
            {
                TMDBConstants.WITHGENRES,
                TMDBConstants.ORSEPARATOR,
                "" + (int) TMDBConstants.Genres.Drama,
                "" + (int) TMDBConstants.Genres.Action,
                "" + (int) TMDBConstants.Genres.SciFi
            };
            urlBuilder.AddDesiredParameters(myGenres);

            string[] sortByParam =
            {
                TMDBConstants.SORTBY,
                TMDBConstants.POPULARITYDESC
            };
            urlBuilder.AddDesiredParameters(sortByParam);

            Assert.AreEqual("https://api.themoviedb.org/3/discover/tv?" +
                            TMDBConstants.TMDBAPIKEY + "&page=3&with_genres=" + (int) TMDBConstants.Genres.Drama
                            + "|" + (int) TMDBConstants.Genres.Action + "|" + (int) TMDBConstants.Genres.SciFi +
                            "&sort_by=" + TMDBConstants.POPULARITYDESC,
                urlBuilder.BuiltURL);

        }
Example #4
0
		public void Construct (IURLBuilder urlBuilder)
		{
			urlBuilder.BuildStartOfURL ();
			urlBuilder.AddSpecificSearch ();
			urlBuilder.AddParameterStartAndAPIKey ();
			urlBuilder.AddPageNum ();
			//urlBuilder.AddDesiredParameters ();
		}
        public void GenerateBaseDiscoverTVURLPage1()
        {
            newManufacturer = new URLManufacturer();
            urlBuilder = new DiscoverTVURLBuilder(1);

            newManufacturer.Construct(urlBuilder);

            Assert.AreEqual("https://api.themoviedb.org/3/discover/tv?" + TMDBConstants.TMDBAPIKEY + "&page=1",
                urlBuilder.BuiltURL);
        }
        private bool AssignInitializeWeatherData()
        {
            try
            {
                if (CitiesComboBox.SelectedItem.GetType().Equals((new ComboBoxItem()).GetType()))
                {
                    _city = ((ComboBoxItem)CitiesComboBox.SelectedItem).Content.ToString();
                }
                else
                {
                    _city = CitiesComboBox.SelectedItem.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Message returned by application: {ex.Message} \n Probably city name is invalid. \n Selected item is {CitiesComboBox.SelectedItem.GetType()}");
                return(false);
            }

            if (OpenWeatherServiceRadio.IsChecked == true)
            {
                try
                {
                    _baseURL           = @"http://api.openweathermap.org/data/2.5/weather";
                    _urlBuilder        = new OpenWeatherAPIURLBuilder(_baseURL, _apiKey);
                    _weatherDownloader = new OpenWeatherDownloader(_urlBuilder);
                    _weatherData       = new OpenWeatherObject();
                    _dataBinder        = new OpenWeatherDataBinder <OpenWeatherObject>();
                    _weatherDownloader.DownloadDataByCity(_city);
                    _weatherData = _dataBinder.DeserializeJSON(_weatherDownloader.PushURL());
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Error: {ex.Message}");
                    return(false);
                }
            }

            if (CitiesComboBox.SelectedItem == null || CitiesComboBox.SelectedItem.ToString().Length == 0)
            {
                MessageBox.Show("You have not selected city!");
                return(false);
            }

            return(true);
        }
        public void Setup()
        {
            if (testMode == "Live")
            {
                repository = new MSSQLDatabase();
                connection = new ComicVineWebConnection();
            }
            else
            {
                repository = new TestRepository();
                connection = new TestWebConnection();
            }

            key = repository.GetSetting("WebServiceKey");
            format = "xml";

            urlBuilder = new ComicVineURLBuilder(key, format);
            reader = new ComicVineXMLReader();
            service = new WebDataService(connection, reader, urlBuilder);
        }
Example #8
0
        public void Setup()
        {
            if (testMode == "Live")
            {
                repository = new MSSQLDatabase();
                connection = new ComicVineWebConnection();
            }
            else
            {
                repository = new TestRepository();
                connection = new TestWebConnection();
            }

            key    = repository.GetSetting("WebServiceKey");
            format = "xml";

            urlBuilder = new ComicVineURLBuilder(key, format);
            reader     = new ComicVineXMLReader();
            service    = new WebDataService(connection, reader, urlBuilder);
        }
        public void GenerateDiscoverTVURLWithGenres()
        {
            newManufacturer = new URLManufacturer();
            urlBuilder = new DiscoverTVURLBuilder(1);

            newManufacturer.Construct(urlBuilder);

            string[] myGenres =
            {
                TMDBConstants.WITHGENRES,
                TMDBConstants.ORSEPARATOR,
                "" + (int) TMDBConstants.Genres.Drama,
                "" + (int) TMDBConstants.Genres.Action,
                "" + (int) TMDBConstants.Genres.SciFi
            };
            urlBuilder.AddDesiredParameters(myGenres);

            Assert.AreEqual("https://api.themoviedb.org/3/discover/tv?" +
                            TMDBConstants.TMDBAPIKEY + "&page=1&with_genres=" + (int) TMDBConstants.Genres.Drama
                            + "|" + (int) TMDBConstants.Genres.Action + "|" + (int) TMDBConstants.Genres.SciFi,
                urlBuilder.BuiltURL);


        }
 public WebDataService(IWebConnection connection, IWebDataReader reader, IURLBuilder urlBuilder)
 {
     this.connection = connection;
     this.reader = reader;
     this.urlBuilder = urlBuilder;
 }
Example #11
0
 public OpenWeatherDownloader(IURLBuilder urlBuilder)
 {
     URLBuilder = urlBuilder;
 }
Example #12
0
 public WebDataService(IWebConnection connection, IWebDataReader reader, IURLBuilder urlBuilder)
 {
     this.connection = connection;
     this.reader     = reader;
     this.urlBuilder = urlBuilder;
 }