コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: monobek/weatherWPF
 public MainWindow()
 {
     InitializeComponent();
     _weatherService     = new GetWeatherService();
     _applicationContext = new ApplicationContext();
     _root = new Root();
 }
コード例 #2
0
 public MainWindow()
 {
     InitializeComponent();
     Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
     _applicationContext = new ApplicationContext();
     _weatherService     = new GetWeatherService();
     _cities             = new GetCity();
     cityList            = _cities.FillCity();
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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");
     }
 }
コード例 #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");
     }
 }
コード例 #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");
     }
 }
コード例 #8
0
ファイル: Weather.xaml.cs プロジェクト: Ramis121/Weather_Full
 public Weather()
 {
     InitializeComponent();
     _weatherServies = new GetWeatherService();
 }
コード例 #9
0
 public MainWindow()
 {
     InitializeComponent();
     str             = new ObservableCollection <string>();
     _weatherServies = new GetWeatherService();
 }
コード例 #10
0
        public async Task DoWork()
        {
            GetWeatherService service = new GetWeatherService(ApiKey, InputLocation, TempUnit);

            Info = await service.GetWeatherInfo();
        }