public void GetValuesWithKey(string key, int value) { var response = new HttpResponseMessage(HttpStatusCode.NotImplemented); "Given an item is in the database" .x(async() => { var item = new ValueItem(key, value); await factory.RespawnDbContext(); await factory.ExecuteDbContextAsync(async context => { await context.ValueItems.AddAsync(item); await context.SaveChangesAsync(); }); }); "When we ask for that item through the API" .x(async() => { response = await client.GetAsync($"api/v1.0/values/{key}"); }); "Then the item is returned with the right information" .x(async() => { response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <ValueItem>(json); result.Key.Should().Be(key); result.Value.Should().Be(value); }); }
private async Task SeedData(City city, IList <Cinema> cinemas, IList <Movie> movies, IList <Session> sessions, IList <Room> rooms, IList <Genre> genres, IList <MovieGenre> movieGenres) { PickCityIdForCinemas(cinemas, city.Id); PickRandomCinemaIdForRooms(rooms, cinemas.Min(c => c.Id), cinemas.Max(c => c.Id)); PickRandomMovieIdForSessions(sessions, movies.Min(m => m.Id), movies.Max(m => m.Id)); PickRandomRoomIdForSessions(sessions, rooms.Min(r => r.Id), rooms.Max(r => r.Id)); PickRandomMovieAndGenreIdForMovieGenres(movieGenres, movies.Min(m => m.Id), movies.Max(m => m.Id), genres.Min(g => g.Id), genres.Max(g => g.Id)); await _factory.ExecuteDbContextAsync(async context => { await context.MovieGenre.AddRangeAsync(movieGenres); await context.Genre.AddRangeAsync(genres); await context.Movie.AddRangeAsync(movies); await context.Room.AddRangeAsync(rooms); await context.Session.AddRangeAsync(sessions); await context.City.AddAsync(city); await context.Cinema.AddRangeAsync(cinemas); await context.SaveChangesAsync(); }); }