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++; } }
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); }
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()); }
public void SearchStationWithoutConditionExpectsNull() { // Arrange var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object)); // Action var result = weatherService.SearchStation(null); // Assert Assert.IsNull(result); }
public void GetStationDataWithEmptyStationNameExpectsNull() { // Arrange var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object)); // Action var result = weatherService.GetStationData(string.Empty); // Assert Assert.IsNull(result); }