public async Task <WeatherApiHttpClientResponse> GetLocalWeatherInfo(string cityName)
        {
            var response = new HttpResponseMessage();

            try
            {
                response = await client.GetAsync(GetUrl() + "v1/current.json?key=" + _weatherApiConfiguration.ApiKey + _queryString + cityName);

                response.EnsureSuccessStatusCode();
                string responseBody = await response.Content.ReadAsStringAsync();

                var weatherApiHttpClientResponse = new WeatherApiHttpClientResponse {
                    Data          = responseBody,
                    IsSuccessFull = response.IsSuccessStatusCode,
                    StatusCode    = response.StatusCode
                };

                return(weatherApiHttpClientResponse);
            }
            catch (HttpRequestException e)
            {
                return(new WeatherApiHttpClientResponse
                {
                    Data = e.Message,
                    IsSuccessFull = false,
                    Exception = e,
                    StatusCode = response.StatusCode
                });
            }
        }
        public async Task <WeatherApiHttpClientResponse> GetAstronomyInfo(string cityName, DateTime?date)
        {
            var response = new HttpResponseMessage();

            try
            {
                var url = GetUrl() + "v1/astronomy.json?key=" + _weatherApiConfiguration.ApiKey + _queryString + cityName;

                if (date == null)
                {
                    date = DateTime.UtcNow;
                }

                url += _dt + date.Value.ToString("yyyy-MM-dd");

                response = await client.GetAsync(url);

                response.EnsureSuccessStatusCode();
                string responseBody = await response.Content.ReadAsStringAsync();

                var weatherApiHttpClientResponse = new WeatherApiHttpClientResponse
                {
                    Data          = responseBody,
                    IsSuccessFull = response.IsSuccessStatusCode,
                    StatusCode    = response.StatusCode
                };

                return(weatherApiHttpClientResponse);
            }
            catch (HttpRequestException e)
            {
                return(new WeatherApiHttpClientResponse
                {
                    Data = e.Message,
                    IsSuccessFull = false,
                    Exception = e,
                    StatusCode = response.StatusCode
                });
            }
        }
        public void Setup()
        {
            _moockLogger = new Mock <ILogger <WeatherInfoController> >();
            _mockinsurwaveWeatherInfoService = new Mock <IInsurwaveWeatherInfoService>();
            _mockmapper = new Mock <IMapper>();

            _current = new Current
            {
                TempC = "11.0",
                TempF = "54.3"
            };

            _location = new Location
            {
                Name      = "London",
                Country   = "United Kingdom",
                Localtime = "2020-11-16 13:02",
                Region    = "City of London, Greater London"
            };

            _currentDetail = new CurrentDetail
            {
                Current  = _current,
                Location = _location
            };

            _astronomyDetail = new AstronomyDetail {
                Astronomy = new Astronomy
                {
                    Astro = new Astro {
                        Sunrise = "07:21 AM",
                        Sunset  = "04:09 PM"
                    }
                },
                Location = _location
            };

            _city = "London";
            _date = DateTime.UtcNow;

            _cityWeatherInfo = new CityWeatherInfo
            {
                City        = _currentDetail.Location.Name,
                Country     = _currentDetail.Location.Country,
                LocalTime   = _currentDetail.Location.Localtime,
                Region      = _currentDetail.Location.Region,
                Temperature = _currentDetail.Current.TempC
            };

            _cityDetailWithTempUnit = new CityDetailWithTempUnit
            {
                City      = _currentDetail.Location.Name,
                Country   = _currentDetail.Location.Country,
                LocalTime = _currentDetail.Location.Localtime,
                Region    = _currentDetail.Location.Region
            };



            WeatherApiHttpClientResponse = new WeatherApiHttpClientResponse
            {
                Data          = JsonConvert.SerializeObject(_currentDetail),
                IsSuccessFull = true,
                StatusCode    = HttpStatusCode.OK
            };

            AstronomyWeatherApiHttpClientResponse = new WeatherApiHttpClientResponse
            {
                Data          = JsonConvert.SerializeObject(_astronomyDetail),
                IsSuccessFull = true,
                StatusCode    = System.Net.HttpStatusCode.OK
            };

            _mockinsurwaveWeatherInfoService.Setup(x => x.GetLocalWeatherInfo(_city)).Returns(Task.FromResult(WeatherApiHttpClientResponse));

            _mockinsurwaveWeatherInfoService.Setup(x => x.GetAstronomyInfo(_city, _date)).Returns(Task.FromResult(AstronomyWeatherApiHttpClientResponse));
            _mockinsurwaveWeatherInfoService.Setup(x => x.GetAstronomyInfo(_city, null)).Returns(Task.FromResult(AstronomyWeatherApiHttpClientResponse));
            //  _moockLogger.Setup(x => x.LogError(It.IsAny<string>(), It.IsAny<Object>()));
            _mockmapper.Setup(x => x.Map <CityWeatherInfo>(It.IsAny <CurrentDetail>())).Returns(_cityWeatherInfo);
            _mockmapper.Setup(x => x.Map <CityDetailWithTempUnit>(It.IsAny <CurrentDetail>())).Returns(_cityDetailWithTempUnit);

            SUT = new WeatherInfoController(_moockLogger.Object, _mockinsurwaveWeatherInfoService.Object, _mockmapper.Object);
        }