public void ParseForecastDailyResponse() { //Get Response response = RestApiHelper.GetResponse(); //Verify the page loaded successfully AssertAPI.AssertPageLoaded(response); //Parse the response forecastDailyResponse = new JsonDeserializer().Deserialize <ForecastDailyResponse>(response); }
/// <summary> /// Returns a list of days with a certain weather type (like clear, rain etc...) /// </summary> /// <param name="forecastDailyResponse">The JsonDeserialized response object of 'Forecast Daily'</param> /// <param name="weatherType">Type of weather as 'MainEnum' Enum (like clear, rain etc...)</param> /// <returns></returns> public static List <ForcastByDay> GetDaysWithWeatherType(ForecastDailyResponse forecastDailyResponse, MainEnum weatherType) { List <ForcastByDay> days = forecastDailyResponse.List.Where(x => x.Weather[0].Main.Equals(EnumHelper.GetDescription(weatherType))).ToList(); return(days); }
//ToDo: Delete if not in use ///// <summary> ///// Returns a list of max temperatures of all days in the response ///// </summary> ///// <param name="forecastDailyResponse">The JsonDeserialized response object of 'Forecast Daily'</param> ///// <returns></returns> //public static List<decimal> GetMaxTemperatures(ForecastDailyResponse forecastDailyResponse) //{ // List<decimal> maxTemps = forecastDailyResponse.List.Select(x => x.Temp.Max).ToList(); // return maxTemps; //} /// <summary> /// Returns a list of days that their temperature is over the received degree /// </summary> /// <param name="forecastDailyResponse">The JsonDeserialized response object of 'Forecast Daily'</param> /// <param name="degree">The minimum degree which will be the base to compare the days' max temperatures /// <returns></returns> public static List <ForcastByDay> GetDaysOverDegree(ForecastDailyResponse forecastDailyResponse, decimal degree) { List <ForcastByDay> days = forecastDailyResponse.List.Where(x => x.Temp.Max > degree).ToList(); return(days); }