public void GivenValidCountryAndCity_WhenGetWeather_WeGetResponse()
        {
            A.CallTo(() => GlobalWeatherSoap.GetWeather(A <string> .Ignored, A <string> .Ignored))
            .Returns(@"<CurrentWeather><Location>abc</Location><Time>1212121</Time><Wind>abc</Wind><Visibility>abc</Visibility><SkyConditions>abc</SkyConditions>
                           <Temperature>abc</Temperature><DewPoint>abc</DewPoint><RelativeHumidity>abc</RelativeHumidity><Pressure>abc</Pressure></CurrentWeather>");

            var response = _sut.GetWeather("Australia", "Sydney");

            response.CurrentWeather.Location.Should().Be("abc");
        }
        public WeatherResult GetWeather(string country, string city)
        {
            try
            {
                var response = _client.GetWeather(city, country);
                if (string.IsNullOrEmpty(response) || response.ToLower() == "data not found")
                {
                    return(null);
                }

                var xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(response);
                var json = JsonConvert.SerializeXmlNode(xmlDoc);
                return(JsonConvert.DeserializeObject <WeatherResult>(json));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 public static CurrentWeather GetCurrentWeather()
 {
     return(ParseXml(WeatherClient.GetWeather("rotterdam", "netherlands")));
 }