public void GetPositions_WhenArgumentsAreNull_ThrowsException()
        {
            try
            {
                _ = _sut.GetPositions(null, null).Result;
            }
            catch (AggregateException ex)
            {
                Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentNullException));
            }

            try
            {
                _ = _sut.GetPositions(null, "foobar").Result;
            }
            catch (AggregateException ex)
            {
                Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentNullException));
            }

            try
            {
                _ = _sut.GetPositions("foobar", null).Result;
            }
            catch (AggregateException ex)
            {
                Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentNullException));
            }
        }
        public async Task <ActionResult <IEnumerable <SearchPosition> > > Get(string searchTerm, string positionTerm, int pages = 10)
        {
            if (string.IsNullOrEmpty(searchTerm))
            {
                return(BadRequest("Search term cannot be blank"));
            }
            if (string.IsNullOrEmpty(positionTerm))
            {
                return(BadRequest("Postion term cannot be blank"));
            }

            try
            {
                var searchPositions = new List <SearchPosition>();
                var url             = $"{Constants.GOOGLE_SEARCH_URL}?q={searchTerm.Trim().Replace(" ", "+")}";
                for (int i = 0; i < pages; i++)
                {
                    string pageString = (i == 0) ? string.Empty : $"&start={i * 10}";

                    searchPositions.Add(new SearchPosition {
                        PageNumber = i + 1, Positions = await _postionExtractor.GetPositions($"{url}{pageString}", positionTerm)
                    });
                }

                return(Ok(searchPositions));
            }
            catch
            {
                var problems = new ValidationProblemDetails
                {
                    Status = (int)HttpStatusCode.InternalServerError,
                    Detail = "Error Occurred!"
                };

                return(ValidationProblem(problems));
            }
        }