예제 #1
0
        public void TestGetWithCity()
        {
            string city = "london";

            var respose = _cityweather.GenerateReportForCity(city);

            dynamic test = JsonConvert.DeserializeObject <Report>(respose);

            if (test.Name.Equals("london_" + DateTime.Now.Date.ToShortDateString()))
            {
                Assert.True(true);
            }
            else
            {
                Assert.False(false);
            }
        }
예제 #2
0
 public ActionResult <string> Get(string city)
 {
     try
     {
         //if (city.Any(ch => !Char.IsLetterOrDigit(ch)) || city.Any(ch => !Char.IsDigit(ch)))
         if (city.Any(ch => !Char.IsLetterOrDigit(ch)))
         {
             var error = "Incorrect city name. Input string without any special character!";
             return(Ok(new { city, error }));
         }
         else
         {
             var data = _cityWeather.GenerateReportForCity(city);
             return(data);
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500, "Internal server error"));
     }
 }