Ejemplo n.º 1
0
        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 + "}");
        }
Ejemplo n.º 2
0
        public async Task get_weatherObservationById()
        {
            WeatherObservation weatherObservation5 = new WeatherObservation
            {
                Id                  = 9,
                Day                 = 24,
                Month               = 3,
                Year                = 2020,
                LocationName        = "Holsterbro",
                Lat                 = 22.77,
                Lon                 = 44.77,
                Temperature         = 23,
                Humidity            = 5,
                AtmosphericPressure = 56
            };

            WeatherObservation weatherObservation6 = new WeatherObservation
            {
                Id                  = 10,
                Day                 = 31,
                Month               = 5,
                Year                = 2004,
                LocationName        = "Skanderborg",
                Lat                 = 80.30,
                Lon                 = 90.11,
                Temperature         = 23,
                Humidity            = 5,
                AtmosphericPressure = 56
            };

            WeatherObservation weatherObservation7 = new WeatherObservation
            {
                Id                  = 11,
                Day                 = 23,
                Month               = 1,
                Year                = 2020,
                LocationName        = "Randers",
                Lat                 = 40.22,
                Lon                 = 88.33,
                Temperature         = 16,
                Humidity            = 5,
                AtmosphericPressure = 56
            };

            WeatherObservation weatherObservation8 = new WeatherObservation
            {
                Id                  = 12,
                Day                 = 14,
                Month               = 2,
                Year                = 2020,
                LocationName        = "Randers",
                Lat                 = 22.55,
                Lon                 = 33.76,
                Temperature         = 10,
                Humidity            = 1,
                AtmosphericPressure = 20
            };

            _context.Add(weatherObservation5);
            _context.Add(weatherObservation6);
            _context.Add(weatherObservation7);
            _context.Add(weatherObservation8);
            _context.SaveChanges();

            var result = _uut.GetWeatherObservation(10)?.Result.Value;


            Assert.AreEqual(10, result.Id);
        }