public void when_reserving_less_seats_than_remaining_then_seats_become_unavailable() { this.sut.MakeReservation(Guid.NewGuid(), 4); this.sut = this.sutProvider.PersistReload(this.sut); Assert.Equal(0, sut.RemainingSeats); }
public void Setup() { this._sut = new SeatsAvailability(ConferenceId, new[] { new AvailableSeatsChanged { Seats = new[] { new SeatQuantity(SeatTypeId, 10) } } }); }
public void when_committing_a_reservation_then_cannot_expire_it() { this.sut.CommitReservation(ReservationId); this.sut = this.sutProvider.PersistReload(this.sut); Assert.Throws <KeyNotFoundException>(() => sut.CancelReservation(ReservationId)); }
public void when_cancelling_a_reservation_then_seats_become_available() { this.sut.CancelReservation(ReservationId); this.sut = this.sutProvider.PersistReload(this.sut); Assert.Equal(10, sut.RemainingSeats); }
protected given_available_seats(IPersistenceProvider sutProvider) { this.sutProvider = sutProvider; this.sut = new SeatsAvailability(TicketTypeId); this.sut.AddSeats(10); this.sut = this.sutProvider.PersistReload(this.sut); }
protected given_some_avilable_seats_and_some_taken(IPersistenceProvider sutProvider) { this.sutProvider = sutProvider; this.sut = new SeatsAvailability(TicketTypeId); this.sut.AddSeats(10); this.sut.MakeReservation(ReservationId, 6); this.sut = this.sutProvider.PersistReload(this.sut); }
public void when_committing_a_reservation_then_remaining_seats_are_not_modified() { var remaining = this.sut.RemainingSeats; this.sut.CommitReservation(ReservationId); this.sut = this.sutProvider.PersistReload(this.sut); Assert.Equal(remaining, this.sut.RemainingSeats); }
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); }
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 Handle(RemoveSeats command) { var availability = repository.Find(command.ConferenceId); if (availability == null) { availability = new SeatsAvailability(command.ConferenceId); } availability.RemoveSeats(command.SeatType, command.Quantity); repository.Save(availability, command.Id.ToString()); }
public given_some_avilable_seats_and_some_taken() { sut = new SeatsAvailability(ConferenceId, new IVersionedEvent[] { new AvailableSeatsChanged { Seats = new[] { new SeatQuantity(SeatTypeId, 10), new SeatQuantity(OtherSeatTypeId, 12) } }, new SeatsReserved { ReservationId = ReservationId, ReservationDetails = new[] { new SeatQuantity(SeatTypeId, 6) }, AvailableSeatsChanged = new[] { new SeatQuantity(SeatTypeId, -6) } } }); }
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 InitializeDatabase(OrmRepository context) { this.innerInitializer.InitializeDatabase(context); // Create views, seed reference data, etc. // TODO: remove hardcoded seats availability. if (context.Set <SeatsAvailability>().Find(Guid.Empty) == null) { var availability = new SeatsAvailability(Guid.Empty); availability.AddSeats(50); context.Save(availability); } context.SaveChanges(); }
public given_an_existing_reservation() { sut = new SeatsAvailability( ConferenceId, new IVersionedEvent[] { new AvailableSeatsChanged { Seats = new[] { new SeatQuantity(SeatTypeId, 10), new SeatQuantity(OtherSeatTypeId, 12) }, Version = 1 }, new SeatsReserved { ReservationId = ReservationId, ReservationDetails = new[] { new SeatQuantity(SeatTypeId, 6) }, AvailableSeatsChanged = new[] { new SeatQuantity(SeatTypeId, -6) }, Version = 2 } }); }
public void Setup() { this._sut = new SeatsAvailability(_conferenceId, new IVersionedEvent[] { new AvailableSeatsChanged() { Seats = new[] { new SeatQuantity(_seatTypeId, 10), new SeatQuantity(_otherSeatTypeId, 12) } }, new SeatsReserved() { ReservationId = _reservationId, ReservationDetails = new[] { new SeatQuantity(_seatTypeId, 6) }, AvailableSeatsChanged = new[] { new SeatQuantity(_seatTypeId, -6) } } }); }
public given_available_seats() { this.sut = new SeatsAvailability(ConferenceId, new[] { new AvailableSeatsChanged { Seats = new[] { new SeatQuantity(SeatTypeId, 10) } } }); }
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 given_an_existing_reservation() { this.sut = new SeatsAvailability( ConferenceId, new IVersionedEvent[] { new AvailableSeatsChanged { Seats = new[] { new SeatQuantity(SeatTypeId, 10) , new SeatQuantity(OtherSeatTypeId, 12) }, Version = 1, }, new SeatsReserved { ReservationId = ReservationId, ReservationDetails = new[] { new SeatQuantity(SeatTypeId, 6) }, AvailableSeatsChanged = new[] { new SeatQuantity(SeatTypeId, -6) }, Version = 2, } }); }
public given_some_avilable_seats_and_some_taken() { this.sut = new SeatsAvailability(ConferenceId, new IVersionedEvent[] { new AvailableSeatsChanged { Seats = new[] { new SeatQuantity(SeatTypeId, 10) , new SeatQuantity(OtherSeatTypeId, 12) } }, new SeatsReserved { ReservationId = ReservationId, ReservationDetails = new[] { new SeatQuantity(SeatTypeId, 6) }, AvailableSeatsChanged = new[] { new SeatQuantity(SeatTypeId, -6) } } }); }