public async Task Test_Seats_Are_Free_After_Hold_Time() { var flightId = Guid.NewGuid(); var userId = "luke"; var holdSeconds = 10; await ForEachSeat(async seat => { await AssertFlightState(flightId, seat, SeatState.Free); var actual = await flightsClient.HoldSeatAsync(flightId, seat, userId, holdSeconds); actual.IsSuccess.Should().BeTrue(); }); await Task.Delay(TimeSpan.FromSeconds(holdSeconds * 2 + 1)); await ForEachSeat(async seat => { var flight = await flightsClient.GetFlightAsync(flightId); flight.Seats.Single(x => x.Id == seat).State.Should().Be(SeatState.Free); }); async Task ForEachSeat(Func <string, Task> func) { foreach (var seatId in new [] { "1A", "1B", "1C" }) { await func(seatId); } } }
public async Task <IActionResult> GetFlight(Guid flightId, string userId) { if (string.IsNullOrEmpty(userId)) { var loginForm = new LoginForm { FlightId = flightId }; return(View("Login", loginForm)); } var flight = await flightsClient.GetFlightAsync(flightId).ConfigureAwait(true); var bookingViewModel = new FlightBookingViewModel { Id = flight.Id, UserId = userId, Number = flight.Number, Date = flight.Date.ToShortDateString(), Rows = BuildSeats(userId, flight) }; return(View("FlightBooking", bookingViewModel)); }