示例#1
0
        public void When_adding_non_existing_seat_type_then_adds_availability()
        {
            var seatType = Guid.NewGuid();

            _sut.AddSeats(seatType, 50);

            Assert.AreEqual(seatType, _sut.SingleEvent <AvailableSeatsChanged>().Seats.Single().SeatType);
            Assert.AreEqual(50, _sut.SingleEvent <AvailableSeatsChanged>().Seats.Single().Quantity);
        }
        public void when_adding_seat_type_then_changes_availability()
        {
            var id = Guid.NewGuid();
            var seatType = Guid.NewGuid();

            var sut = new SeatsAvailability(id);
            sut.AddSeats(seatType, 50);

            Assert.Equal(seatType, sut.SingleEvent<AvailableSeatsChanged>().Seats.Single().SeatType);
            Assert.Equal(50, sut.SingleEvent<AvailableSeatsChanged>().Seats.Single().Quantity);
        }
示例#3
0
        public void When_adding_seat_type_then_changes_availability()
        {
            var id       = Guid.NewGuid();
            var seatType = Guid.NewGuid();

            var seatsAvailability = new SeatsAvailability(id);

            seatsAvailability.AddSeats(seatType, 50);

            Assert.AreEqual(seatType, seatsAvailability.SingleEvent <AvailableSeatsChanged>().Seats.Single().SeatType);
            Assert.AreEqual(50, seatsAvailability.SingleEvent <AvailableSeatsChanged>().Seats.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_reserving_less_seats_than_remaining_then_seats_are_reserved()
        {
            sut.MakeReservation(Guid.NewGuid(), new[] { new SeatQuantity(SeatTypeId, 4) });

            Assert.Equal(SeatTypeId, sut.SingleEvent <SeatsReserved>().ReservationDetails.ElementAt(0).SeatType);
            Assert.Equal(4, sut.SingleEvent <SeatsReserved>().ReservationDetails.ElementAt(0).Quantity);
            Assert.Equal(SeatTypeId, sut.SingleEvent <SeatsReserved>().AvailableSeatsChanged.ElementAt(0).SeatType);
            Assert.Equal(-4, sut.SingleEvent <SeatsReserved>().AvailableSeatsChanged.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);
        }
        public void when_committing_then_commits_reservation_id()
        {
            sut.CommitReservation(ReservationId);

            Assert.Equal(ReservationId, sut.SingleEvent <SeatsReservationCommitted>().ReservationId);
        }
 public void When_committing_then_commits_reservation_id()
 {
     _sut.CommitReservation(_reservationId);
     Assert.AreEqual(_reservationId, _sut.SingleEvent <SeatsReservationCommitted>().ReservationId);
 }