Esempio n. 1
0
        public async void PostWeatherObservation_CreatesCorrectObservation()
        {
            dbcontext.Database.EnsureCreated();
            var hugo = new WeatherObservation {
                Date = DateTime.Now, Location = new Location {
                    Name = "København"
                }
            };
            await uut.PostWeatherObservation(hugo);

            var a = await uut.GetWeatherObservation();

            List <WeatherObservation> li = a.Value.ToList();

            Assert.Equal("København", li.ElementAt(0).Location.Name);
            dbcontext.Database.EnsureDeleted();
        }
Esempio n. 2
0
        public async Task PostWeatherObservationAddsToDb()
        {
            using (var context = new ApplicationContext(_options))
            {
                context.Database.EnsureCreated();
                int initial = context.WeatherObservations.ToList().Count;
                WeatherObservationsController uut   = new WeatherObservationsController(context, _hubContext);
                WeatherObservation            entry = new WeatherObservation()
                {
                    LocationName = "Poland",
                    Temperature  = 120
                };
                await uut.PostWeatherObservation(entry);

                Assert.Equal(initial + 1, context.WeatherObservations.ToList().Count);
            }
        }