Beispiel #1
0
 public MainWindow()
 {
     InitializeComponent();
     _weatherService     = new GetWeatherService();
     _applicationContext = new ApplicationContext();
     _root = new Root();
 }
Beispiel #2
0
 public MainWindow()
 {
     InitializeComponent();
     Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
     _applicationContext = new ApplicationContext();
     _weatherService     = new GetWeatherService();
     _cities             = new GetCity();
     cityList            = _cities.FillCity();
 }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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");
     }
 }
Beispiel #6
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");
     }
 }
Beispiel #7
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");
     }
 }
Beispiel #8
0
 public Weather()
 {
     InitializeComponent();
     _weatherServies = new GetWeatherService();
 }
 public MainWindow()
 {
     InitializeComponent();
     str             = new ObservableCollection <string>();
     _weatherServies = new GetWeatherService();
 }
Beispiel #10
0
        public async Task DoWork()
        {
            GetWeatherService service = new GetWeatherService(ApiKey, InputLocation, TempUnit);

            Info = await service.GetWeatherInfo();
        }