public async void ByDateWeatherGetsCorrectDataTest() { _db.Database.EnsureCreated(); var testWeather = new WheatherDatoes { Date = new DateTime(2021, 05, 24), place = new Location { Name = "Lalandia" }, TemperatureC = 32 }; var testWeather1 = new WheatherDatoes { Date = new DateTime(2021, 05, 24), place = new Location { Name = "Frederecia" }, TemperatureC = 22 }; var testWeather2 = new WheatherDatoes { Date = new DateTime(2021, 05, 24), place = new Location { Name = "Aalborg" }, TemperatureC = 34 }; var testWeather3 = new WheatherDatoes { Date = new DateTime(2021, 05, 24), place = new Location { Name = "Aarhus" }, TemperatureC = 12 }; var testWeather4 = new WheatherDatoes { Date = new DateTime(2021, 05, 23), place = new Location { Name = "Billund" }, TemperatureC = 25 }; var testWeather5 = new WheatherDatoes { Date = new DateTime(2021, 05, 22), place = new Location { Name = "Esbjerg" }, TemperatureC = 14 }; _db.WheatherDato.AddRange(testWeather, testWeather1, testWeather2, testWeather3, testWeather4, testWeather5); _db.SaveChanges(); var test = await _uut.GetByDateWeatherData(new DateTime(2021, 05, 24)); List <WheatherDato> weatherList = test.Value.ToList(); Assert.Equal(4, weatherList.Count); Assert.Collection(weatherList, item => Assert.Equal("Lalandia", item.place.Name), item => Assert.Equal("Frederecia", item.place.Name), item => Assert.Equal("Aalborg", item.place.Name), item => Assert.Equal("Aarhus", item.place.Name)); _db.Database.EnsureDeleted(); }
public async void PostWeatherCorrectPlaceTest() { _db.Database.EnsureCreated(); var testWeather = new WheatherDatoes { Date = DateTime.Now, place = new Location { Name = "Lalandia" }, TemperatureC = 32 }; await _uut.PostWheatherDato(testWeather); var test = await _uut.GetWheatherDato(); List <WheatherDato> weatherList = test.Value.ToList(); Assert.Equal("Lalandia", weatherList.ElementAt(0).place.Name); _db.Database.EnsureDeleted(); }
public async void GetWeatherCorrectPlaceTest() { _db.Database.EnsureCreated(); var testWeather = new WheatherDatoes { Date = DateTime.Now, place = new Location { Name = "Singapore" }, TemperatureC = 32 }; _db.WheatherDato.Add(testWeather); _db.SaveChanges(); var test = await _uut.GetByDateWeatherData(DateTime.Now); Assert.Equal("Singapore", test.Value.ElementAt(0).place.Name); _db.Database.EnsureDeleted(); }