예제 #1
0
        public async Task Call_both_auditorium_layout_api_and_reservation_api_when_getting_a_given_show()
        {
            var showId             = "666";
            var auditoriumProvider = Substitute.For <IProvideAuditoriumSeating>();

            auditoriumProvider.GetAuditoriumSeatingFor(showId)
            .Returns(AuditoriumDtoBuilder.From("A1", "A2", "B1", "B2", "C1", "C2").Build());

            var reservationsProvider = Substitute.For <IProvideReservedSeats>();

            reservationsProvider.GetReservedSeats(showId)
            .Returns(new ReservedSeatsDto(new List <string> {
                "A2", "B1", "C1", "C2"
            }));

            var controller = new ShowsController(auditoriumProvider, reservationsProvider,
                                                 Substitute.For <ISuggestSeats>(), Substitute.For <IProvidePrices>(), null, null, null);

            var showDto = (await controller.GetShow(showId)).Value;


            TestContext.WriteLine(JsonConvert.SerializeObject(showDto, Formatting.Indented));

            Check.That(showDto.Rows.Keys).ContainsExactly("A", "B", "C");

            Check.That(showDto.Rows["A"].Select(s => s.ReservationStatus))
            .ContainsExactly(ReservationStatus.Available, ReservationStatus.Reserved);
            Check.That(showDto.Rows["B"].Select(s => s.ReservationStatus))
            .ContainsExactly(ReservationStatus.Reserved, ReservationStatus.Available);
            Check.That(showDto.Rows["C"].Select(s => s.ReservationStatus))
            .ContainsExactly(ReservationStatus.Reserved, ReservationStatus.Reserved);
        }