public void GetFormatAsStringDefaultTest()
        {
            FlickrSearchRequest request = new FlickrSearchRequest();
            string format = request.GetFormatAsString();

            Assert.AreEqual(Constants.JSON, format);
        }
        public void GetFormatAsStringJsonTest()
        {
            FlickrSearchRequest request = new FlickrSearchRequest();

            request.Format = eSupportedFormat.JSON;
            string format = request.GetFormatAsString();

            Assert.AreEqual(Constants.JSON, format);
        }
Example #3
0
        public void GetResponseNullTest()
        {
            _request = null;
            _service = new FlickrSearchService(_request);

            var responseTask = _service.GetServiceResponse();

            responseTask.Wait();

            Assert.IsNull(responseTask.Result);
        }
Example #4
0
        public void GetResponseFailTest()
        {
            _request = new FlickrSearchRequest();
            _service = new FlickrSearchService(_request);

            var responseTask = _service.GetServiceResponse();

            responseTask.Wait();

            Assert.IsNotNull(responseTask.Result);

            Assert.AreEqual(Constants.SEARCH_FAIL, responseTask.Result.stat);
        }
        public void GetResponseTextNoResultTest()
        {
            _request      = new FlickrSearchRequest();
            _request.Text = "dsdsfsdfsdfsf";
            _service      = new FlickrSearchService(_request);

            var responseTask = _service.GetServiceResponse();

            responseTask.Wait();

            Assert.IsNotNull(responseTask.Result);

            Assert.AreEqual(Constants.SEARCH_OK, responseTask.Result.stat);

            Assert.AreEqual(0, responseTask.Result.photos.total);
        }
        public void GetResponseValidTextTest()
        {
            _request      = new FlickrSearchRequest();
            _request.Text = "nature";
            _service      = new FlickrSearchService(_request);

            var responseTask = _service.GetServiceResponse();

            responseTask.Wait();

            Assert.IsNotNull(responseTask.Result);

            Assert.AreEqual(Constants.SEARCH_OK, responseTask.Result.stat);

            Assert.IsNotNull(responseTask.Result.photos);
        }
Example #7
0
        public void GetResponsePerPageTest([Values(0)] int input)
        {
            _request      = new FlickrSearchRequest();
            _request.Text = "nature";
            _service      = new FlickrSearchService(_request);

            var responseTask = _service.GetServiceResponse();

            responseTask.Wait();

            Assert.IsNotNull(responseTask.Result);

            Assert.AreEqual(Constants.SEARCH_OK, responseTask.Result.stat);

            Assert.IsNotNull(responseTask.Result.photos);

            Assert.AreEqual(100, responseTask.Result.photos.perpage);
        }
Example #8
0
        public void GetResponsePerPageLimitTest([Values(10, 20, 50, 150, 95, 499, 350, 198, 500)] int input)
        {
            _request         = new FlickrSearchRequest();
            _request.Text    = "nature";
            _request.PerPage = (Int16)input;
            _service         = new FlickrSearchService(_request);

            var responseTask = _service.GetServiceResponse();

            responseTask.Wait();

            Assert.IsNotNull(responseTask.Result);

            Assert.AreEqual(Constants.SEARCH_OK, responseTask.Result.stat);

            Assert.IsNotNull(responseTask.Result.photos);

            Assert.AreEqual(input, responseTask.Result.photos.perpage);
        }
Example #9
0
        public Search()
        {
            try
            {
                InitializeComponent();

                lblImageResult.Visible  = true;
                lblErrorMessage.Visible = true;
                lblImageResult.Text     = string.Empty;
                lblErrorMessage.Text    = string.Empty;

                _flickrSearchRequest = new FlickrSearchRequest();
                _flickrSearchService = new FlickrSearchService(_flickrSearchRequest);

                _flickrSearchRequest.ApiKey = ConfigurationManager.AppSettings["api_key"];

                bwDownloadImages.WorkerSupportsCancellation = true;
            }
            catch (Exception ex)
            {
                Logger.WriteLog("Exception in Search");
                Logger.WriteLog(ex.Message);
            }
        }
Example #10
0
 public FlickrSearchService(FlickrSearchRequest request)
 {
     this._request = request;
     _httpResponse = new HttpResponse();
 }