Exemplo n.º 1
0
        public async void GetWeatherObservationBetweenDates_ReturnsCorrectObservations()
        {
            dbcontext.Database.EnsureCreated();
            var hugo = new WeatherObservation
            {
                Date = new DateTime(2020, 12, 12), Location = new Location {
                    Name = "Hornslet"
                }
            };
            var hugo2 = new WeatherObservation
            {
                Date = new DateTime(2020, 11, 11), Location = new Location {
                    Name = "København"
                }
            };
            var hugo3 = new WeatherObservation
            {
                Date = new DateTime(2020, 10, 10), Location = new Location {
                    Name = "Aarhus"
                }
            };
            var hugo4 = new WeatherObservation
            {
                Date = new DateTime(2000, 12, 12), Location = new Location {
                    Name = "Dårlig By"
                }
            };
            var hugo5 = new WeatherObservation
            {
                Date = new DateTime(2000, 10, 10), Location = new Location {
                    Name = "Dårlig By 2"
                }
            };

            dbcontext.WeatherObservation.AddRange(hugo, hugo2, hugo3, hugo4, hugo5);
            dbcontext.SaveChanges();

            var a = await uut.GetWeatherObservationBetweenDate(new DateTime(2000, 10, 10), new DateTime(2020, 10, 10));

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

            Assert.Equal(3, li.Count);
            Assert.Collection(
                li,
                item => Assert.Equal("Aarhus", item.Location.Name),
                item => Assert.Equal("Dårlig By", item.Location.Name),
                item => Assert.Equal("Dårlig By 2", item.Location.Name)
                );

            dbcontext.Database.EnsureDeleted();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public async void GetWeatherObservation_GetsCorrectObservation()
        {
            dbcontext.Database.EnsureCreated();
            var hugo = new WeatherObservation {
                Date = DateTime.Now, Location = new Location {
                    Name = "Fredericia"
                }
            };

            dbcontext.WeatherObservation.Add(hugo);
            dbcontext.SaveChanges();


            var a = await uut.GetWeatherObservationByDate(DateTime.Now);

            Assert.Equal("Fredericia", a.Value.ElementAt(0).Location.Name);
            dbcontext.Database.EnsureDeleted();
        }