public async Task ShouldReturnForecast() { Fixture fixture = new Fixture(); List <Forecast> q = new List <Forecast>(fixture.CreateMany <Forecast>(25)); var jokes = fixture.CreateMany <string>(25).ToArray(); _context.Forecasts.AddRange(q); _context.SaveChanges(); //Act var result = await _controller.GetAsync(); //Assert var i = 0; var forecasts = q.ToArray(); foreach (var item in result) { Assert.Equal(jokes[i], item.Summary); Assert.Equal(forecasts[i].Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), item.Date); Assert.Equal(forecasts[i].TemperatureC, item.TemperatureC); i++; } }
static internal void InitializeDbForTests(BrendaContext db) { db.Forecasts.RemoveRange(db.Forecasts); db.Forecasts.AddRange(SeedForecasts); db.SaveChanges(); }