public async Task Test_Workflow_CinemaHalls_Valid() { Logger.Info("Load cinema halls ..."); var response = await Get(BaseUrl, EndpointCinemaHalls); await CheckResponseAndLogStatusCodeAsync(Logger, response); var cinemaHalls = JsonConvert.DeserializeObject <IEnumerable <CinemaHallDto> >( await response.Content.ReadAsStringAsync() ).ToList(); cinemaHalls.Should().HaveCount(DataSeeder.CinemaHalls.Count); Logger.Info(cinemaHalls.ToPrettyString()); var newHall = new CinemaHallDto { Label = "New Hall", SizeColumn = 10, SizeRow = 5 }; var updateHallReservations = cinemaHalls.First(c => DataSeeder.Reservations .Select(r => DataSeeder.Schedules.First(s => r.ScheduleId == s.Id).CinemaHallId) .Contains(c.Id)); var updateHall = cinemaHalls.First(c => !DataSeeder.Reservations .Select(r => DataSeeder.Schedules.First(s => r.ScheduleId == s.Id).CinemaHallId) .Contains(c.Id)); updateHall.Label = "Renovated Hall"; var deleteReferencedHall = DataSeeder.CinemaHalls .First(c => DataSeeder.Rows.Select(r => r.CinemaHallId).Contains(c.Id)).Id; var deletedHall = DataSeeder.CinemaHalls .Last(c => !DataSeeder.Rows.Select(r => r.CinemaHallId).Contains(c.Id)) .Id; await Authenticate(AdminUser, AdminPassword); Logger.Info($"Add new cinema hall: ${newHall.ToPrettyString()} ..."); response = await Post(BaseUrl, EndpointCinemaHall, newHall); await CheckResponseAndLogStatusCodeAsync(Logger, response, HttpStatusCode.Created); var newId = await GetCreatedIdAsync(response); Logger.Info($"Try update cinema hall with reservations: {updateHallReservations.ToPrettyString()} ..."); response = await Put(BaseUrl, EndpointCinemaHall, updateHallReservations); await CheckResponseAndLogStatusCodeAsync(Logger, response, HttpStatusCode.BadRequest); Logger.Info($"Update cinema hall: ${updateHall.ToPrettyString()} ..."); response = await Put(BaseUrl, EndpointCinemaHall, updateHall); await CheckResponseAndLogStatusCodeAsync(Logger, response, HttpStatusCode.NoContent); Logger.Info($"Try delete referenced cinema hall: {deleteReferencedHall.ToPrettyString()} ..."); response = await Delete(BaseUrl, $"{EndpointCinemaHall}/{deleteReferencedHall}"); await CheckResponseAndLogStatusCodeAsync(Logger, response, HttpStatusCode.BadRequest); Logger.Info($"Delete cinema hall: ${deletedHall.ToPrettyString()} ..."); response = await Delete(BaseUrl, $"{EndpointCinemaHall}/{deletedHall}"); await CheckResponseAndLogStatusCodeAsync(Logger, response, HttpStatusCode.NoContent); Logger.Info("Load cinema halls ..."); response = await Get(BaseUrl, EndpointCinemaHalls); await CheckResponseAndLogStatusCodeAsync(Logger, response); cinemaHalls = JsonConvert.DeserializeObject <IEnumerable <CinemaHallDto> >( await response.Content.ReadAsStringAsync() ).ToList(); var cinemaHall = cinemaHalls.Select(g => g.Id).ToList(); cinemaHall.Should().Contain(newId); cinemaHall.Should().Contain(updateHallReservations.Id); cinemaHall.Should().Contain(updateHall.Id); cinemaHall.Should().Contain(deleteReferencedHall); cinemaHall.Should().NotContain(deletedHall); cinemaHalls.First(g => g.Id == newId).Label.Should().Be(newHall.Label); cinemaHalls.First(g => g.Id == updateHall.Id).Label.Should().Be(updateHall.Label); Logger.Info(cinemaHalls.ToPrettyString()); }