public void When_reserving_more_seats_than_total_then_reserves_total() { var id = Guid.NewGuid(); _sut.MakeReservation(id, new[] { new SeatQuantity(SeatTypeId, 11) }); Assert.AreEqual(SeatTypeId, this._sut.SingleEvent <SeatsReserved>().ReservationDetails.ElementAt(0).SeatType); Assert.AreEqual(10, this._sut.SingleEvent <SeatsReserved>().ReservationDetails.ElementAt(0).Quantity); }
public void when_reserving_less_seats_than_remaining_then_seats_are_reserved() { sut.MakeReservation(Guid.NewGuid(), new[] { new SeatQuantity(SeatTypeId, 4) }); Assert.Equal(SeatTypeId, this.sut.SingleEvent <SeatsReserved>().ReservationDetails.ElementAt(0).SeatType); Assert.Equal(4, this.sut.SingleEvent <SeatsReserved>().ReservationDetails.ElementAt(0).Quantity); Assert.Equal(SeatTypeId, this.sut.SingleEvent <SeatsReserved>().AvailableSeatsChanged.ElementAt(0).SeatType); Assert.Equal(-4, this.sut.SingleEvent <SeatsReserved>().AvailableSeatsChanged.ElementAt(0).Quantity); }
public void when_reserving_more_seats_than_remaining_then_rejects() { var id = Guid.NewGuid(); sut.MakeReservation(id, 5); Assert.Equal(id, ((ReservationRejected)sut.Events.Last()).ReservationId); }
public void when_reserving_more_seats_than_total_then_rejects() { var id = Guid.NewGuid(); sut.MakeReservation(id, 11); Assert.Equal(1, sut.Events.Count()); Assert.Equal(id, ((ReservationRejected)sut.Events.Single()).ReservationId); }
public void when_updating_reservation_with_more_seats_then_reserves_all_requested() { sut.MakeReservation(ReservationId, new[] { new SeatQuantity(SeatTypeId, 8) }); Assert.Equal(ReservationId, sut.SingleEvent <SeatsReserved>().ReservationId); Assert.Equal(SeatTypeId, sut.SingleEvent <SeatsReserved>().ReservationDetails.Single().SeatType); Assert.Equal(8, sut.SingleEvent <SeatsReserved>().ReservationDetails.Single().Quantity); }
public void when_regenerating_from_memento_then_can_continue() { var memento = sut.SaveToMemento(); sut = new SeatsAvailability(sut.Id, memento, Enumerable.Empty <IVersionedEvent>()); Assert.Equal(2, sut.Version); sut.MakeReservation(ReservationId, new[] { new SeatQuantity(OtherSeatTypeId, 3) }); Assert.Equal(2, sut.SingleEvent <SeatsReserved>().AvailableSeatsChanged.Count()); Assert.Equal(-3, sut.SingleEvent <SeatsReserved>().AvailableSeatsChanged.Single(x => x.SeatType == OtherSeatTypeId).Quantity); Assert.Equal(6, sut.SingleEvent <SeatsReserved>().AvailableSeatsChanged.Single(x => x.SeatType == SeatTypeId).Quantity); Assert.Equal(3, sut.SingleEvent <SeatsReserved>().Version); }
public void when_removing_seats_to_existing_seat_type_then_removes_remaining_seats() { sut.RemoveSeats(SeatTypeId, 5); sut.MakeReservation(Guid.NewGuid(), new[] { new SeatQuantity(SeatTypeId, 10) }); Assert.Equal(SeatTypeId, sut.Events.OfType <AvailableSeatsChanged>().Last().Seats.Single().SeatType); Assert.Equal(-5, sut.Events.OfType <AvailableSeatsChanged>().Last().Seats.Single().Quantity); Assert.Equal(5, sut.Events.OfType <SeatsReserved>().Single().ReservationDetails.ElementAt(0).Quantity); }
public void when_regenerating_from_memento_then_can_continue() { var memento = sut.SaveToMemento(); sut = new SeatsAvailability(sut.Id, memento, Enumerable.Empty<IVersionedEvent>()); Assert.Equal(2, sut.Version); sut.MakeReservation(ReservationId, new[] { new SeatQuantity(OtherSeatTypeId, 3) }); Assert.Equal(2, sut.SingleEvent<SeatsReserved>().AvailableSeatsChanged.Count()); Assert.Equal(-3, sut.SingleEvent<SeatsReserved>().AvailableSeatsChanged.Single(x => x.SeatType == OtherSeatTypeId).Quantity); Assert.Equal(6, sut.SingleEvent<SeatsReserved>().AvailableSeatsChanged.Single(x => x.SeatType == SeatTypeId).Quantity); Assert.Equal(3, sut.SingleEvent<SeatsReserved>().Version); }