public async void GetWeatherObservationBetweenIntervals_FindBetween8And9_5ObservationsIsBetweenInterval() { UnitTests u = new UnitTests(); int count = 0; foreach (var w in _listOfWeatherObservations) { if (count < 5) { w.Date = new DateTime(2019, 12, 02, 08, 30, 00); await _uut.PostWeatherObservation(w); } else { w.Date = new DateTime(2019, 12, 02, 10, 30, 00); await _uut.PostWeatherObservation(w); } count++; } ActionResult <List <WeatherObservation> > weatherData = new List <WeatherObservation>(); DateTime start = new DateTime(2019, 12, 02, 08, 00, 00); DateTime end = new DateTime(2019, 12, 02, 09, 00, 00); weatherData = await _uut.GetWeatherObservationBetweenIntervals(start, end); Assert.That(weatherData.Value.Count, Is.EqualTo(5)); }
public async void GetWeatherObservationByDate_Date201911202_Return0CorrectObservations() { UnitTests u = new UnitTests(); int count = 0; foreach (var w in _listOfWeatherObservations) { if (count < 1) { w.Date = new DateTime(2019, 12, 02, 08, 30, 00); await _uut.PostWeatherObservation(w); } else { w.Date = new DateTime(2019, 12, 05, 10, 30, 00); await _uut.PostWeatherObservation(w); } count++; } ActionResult <List <WeatherObservation> > weatherData = new List <WeatherObservation>(); DateTime getDate = new DateTime(2020, 12, 02, 08, 30, 00); weatherData = await _uut.GetWeatherByDate(getDate); Assert.AreNotEqual(1, weatherData.Value.Count); }
public async void PosttWeatherData_3ObservationPosted_3CorrectInserted() { //Change count < 1 to check for more insertions UnitTests u = new UnitTests(); int count = 0; foreach (var w in _listOfWeatherObservations) { if (count < 3) { await _uut.PostWeatherObservation(w); } else { break; } count++; } ActionResult <IEnumerable <WeatherObservation> > PostedData = new List <WeatherObservation>(); PostedData = await _uut.GetWeatherObservation(); Assert.That(PostedData.Value.ElementAt(0).Location.Name, Is.EqualTo("Horsens")); Assert.That(PostedData.Value.ElementAt(1).Location.Name, Is.EqualTo("Aarhus")); Assert.That(PostedData.Value.ElementAt(2).Location.Name, Is.EqualTo("Herning")); }
public async void GetLatestWeatherData_10DocumentsAvailable_Return5() { UnitTests u = new UnitTests(); foreach (var w in _listOfWeatherObservations) { await _uut.PostWeatherObservation(w); } ActionResult <List <WeatherObservation> > lastFiveWo = new List <WeatherObservation>(); lastFiveWo = await _uut.GetLatestWeatherData(); Assert.That(lastFiveWo.Value.Count, Is.EqualTo(5)); }
public async void PosttWeatherData_Posted10Observations_NumberOfObservationsIs10() { UnitTests u = new UnitTests(); foreach (var w in _listOfWeatherObservations) { await _uut.PostWeatherObservation(w); } ActionResult <IEnumerable <WeatherObservation> > PostedData = new List <WeatherObservation>(); PostedData = await _uut.GetWeatherObservation(); Assert.That(PostedData.Value.Count, Is.EqualTo(10)); }
public async void GetWeatherObservation_10Added_DataCorrectReturned() { UnitTests u = new UnitTests(); foreach (var w in _listOfWeatherObservations) { await _uut.PostWeatherObservation(w); } ActionResult <IEnumerable <WeatherObservation> > weatherData = new List <WeatherObservation>(); weatherData = await _uut.GetWeatherObservation(); var wdInDb = JsonConvert.SerializeObject(weatherData); var wdInList = JsonConvert.SerializeObject(_listOfWeatherObservations); string s = "{\"Result\":null,\"Value\":"; Assert.AreEqual(wdInDb, s + wdInList + "}"); }
public async void GetLatestWeatherData_10DocumentsAvailable_ReturnCorrect5() { UnitTests u = new UnitTests(); foreach (var w in _listOfWeatherObservations) { await _uut.PostWeatherObservation(w); } ActionResult <List <WeatherObservation> > lastFiveWo = new List <WeatherObservation>(); lastFiveWo = await _uut.GetLatestWeatherData(); var wdInDb = JsonConvert.SerializeObject(lastFiveWo); Assert.AreEqual(lastFiveWo.Value.ElementAt(0).Location.Name, "Aalborg"); Assert.AreEqual(lastFiveWo.Value.ElementAt(1).Location.Name, "Skive"); Assert.AreEqual(lastFiveWo.Value.ElementAt(2).Location.Name, "Viborg"); Assert.AreEqual(lastFiveWo.Value.ElementAt(3).Location.Name, "Haderslev"); Assert.AreEqual(lastFiveWo.Value.ElementAt(4).Location.Name, "Koebenhavn"); }
public async void GetWeatherObservationBetweenIntervals_FindBetween8And9_NoDataIsBetweenInterval() { UnitTests u = new UnitTests(); foreach (var w in _listOfWeatherObservations) { w.Date = new DateTime(2019, 12, 02, 09, 30, 00); await _uut.PostWeatherObservation(w); } ActionResult <List <WeatherObservation> > weatherData = new List <WeatherObservation>(); DateTime start = new DateTime(2019, 12, 02, 08, 00, 00); DateTime end = new DateTime(2019, 12, 02, 09, 00, 00); weatherData = await _uut.GetWeatherObservationBetweenIntervals(start, end); var wdInDb = JsonConvert.SerializeObject(weatherData); var wdInList = JsonConvert.SerializeObject(_listOfWeatherObservations); string s = "{\"Result\":null,\"Value\":"; Assert.AreNotEqual(wdInDb, s + wdInList + "}"); }