コード例 #1
0
        public async void GetForecast(City city, FrameworkElement forecast)
        {
            WeatherService service = new WeatherService();
            var donnees = await service.GetForecastByCityAsync(city);

            List<WeatherForecast> listForecast = new List<WeatherForecast>();
            var i = 0;
            foreach (var fcast in donnees)
            {
                if (i < 5)
                    listForecast.Add(fcast);
                else break;

                i++;
            }

            
        }
コード例 #2
0
        public void GetStationDataWithCorrectDataExpectsDataReturn()
        {
            // Arrange
            _datasourceMock.Setup(x => x.BuildDataSource<Observations>())
                          .Returns(new Observations
                          {
                              Observation = new[] { new Observation { StationName = "Station Name 1", DateTime = new DateTime(2013, 4, 11) } }
                          });
            var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object));

            // Action
            var result = weatherService.GetStationData("Station Name 1");

            // Assert
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("Station Name 1", result.FirstOrDefault().StationName);
            Assert.AreEqual(new DateTime(2013, 4, 11), result.FirstOrDefault().DateTime);
        }
コード例 #3
0
        public void GetStationDataWithDummyStationNameExpectsNoObjectReturn()
        {
            // Arrange
            _datasourceMock.Setup(x => x.BuildDataSource<Observations>())
                          .Returns(new Observations
                          {
                              Observation = new[] { new Observation { StationName = "Station Name 1", DateTime = new DateTime(2013, 4, 11) } }
                          });
            var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object));

            // Action
            var result = weatherService.GetStationData("This is dummy station");

            // Assert
            Assert.AreEqual(0, result.Count());
        }
コード例 #4
0
        public void SearchStationWithoutConditionExpectsNull()
        {
            // Arrange
            var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object));

            // Action
            var result = weatherService.SearchStation(null);

            // Assert
            Assert.IsNull(result);
        }
コード例 #5
0
        public void GetStationDataWithEmptyStationNameExpectsNull()
        {
            // Arrange
            var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object));

            // Action
            var result = weatherService.GetStationData(string.Empty);

            // Assert
            Assert.IsNull(result);
        }