Пример #1
0
        public void GetWeatherInfo_NoLocation_ReturnsCorrectInfo()
        {
            GetWeatherService service = new GetWeatherService(null, null);
            var result = service.GetWeatherInfo().Result;

            Assert.AreEqual("Paularino (US)", result.Location);
            Assert.AreEqual(10.96f, result.Temp, 0.1);
            Assert.AreEqual(8.7f, result.TempMin, 0.1);
            Assert.AreEqual(13.3f, result.TempMax, 0.1);
            Assert.AreEqual(4.07f, result.Wind, 0.1);
            Assert.AreEqual(96, result.Humidity);
        }
Пример #2
0
        public void GetWeatherInfo_WithZipCode_ReturnsCorrectInfo()
        {
            GetWeatherService service = new GetWeatherService(null, "92704,us");
            var result = service.GetWeatherInfo().Result;

            Assert.AreEqual("Santa Ana (US)", result.Location);
            Assert.AreEqual(11.02f, result.Temp, 0.1);
            Assert.AreEqual(8.7f, result.TempMin, 0.1);
            Assert.AreEqual(13.3f, result.TempMax, 0.1);
            Assert.AreEqual(1.45, result.Wind, 0.1);
            Assert.AreEqual(89, result.Humidity);
        }
Пример #3
0
 public void GetWeatherInfo_NoLocation_ThrowArgumentException()
 {
     try
     {
         GetWeatherService service = new GetWeatherService(null, "");
         var _ = service.GetWeatherInfo().Result;
         Assert.Fail();
     }
     catch (AggregateException e)
     {
         Assert.AreEqual(
             typeof(InsufficientDataException), e.InnerException.GetType(),
             "Unable to retrieve location information");
     }
 }
Пример #4
0
 public void GetWeatherInfo_InvalidLocation_ThrowArgumentException()
 {
     try
     {
         GetWeatherService service = new GetWeatherService(null, "heaven");
         var _ = service.GetWeatherInfo().Result;
         Assert.Fail();
     }
     catch (AggregateException e)
     {
         Assert.AreEqual(
             typeof(ArgumentException), e.InnerException.GetType(),
             "Provided location is not found");
     }
 }
Пример #5
0
 public void GetWeatherInfo_WrongApiKey_ThrowArgumentException()
 {
     try
     {
         GetWeatherService service = new GetWeatherService("qwerty", "92704, us");
         var _ = service.GetWeatherInfo().Result;
         Assert.Fail();
     }
     catch (AggregateException e)
     {
         Assert.AreEqual(
             typeof(ArgumentException), e.InnerException.GetType(),
             "Api Key is incorrect");
     }
 }
Пример #6
0
        public async Task DoWork()
        {
            GetWeatherService service = new GetWeatherService(ApiKey, InputLocation, TempUnit);

            Info = await service.GetWeatherInfo();
        }