public void TryAcceptReturnsNothingOnInsufficientCapacity( Reservation reservation, Reservation[] reservations, MaîtreD sut) { var reservedSeats = reservations.Sum(r => r.Quantity); sut = sut.WithCapacity(reservedSeats + reservation.Quantity - 1); var actual = sut.TryAccept(reservations, reservation); Assert.True(actual.IsNothing); Assert.False(reservation.IsAccepted); }
public void TryAcceptReturnsReservationInHappyPathScenario( Reservation reservation, Reservation[] reservations, MaîtreD sut, int excessCapacity) { var reservedSeats = reservations.Sum(r => r.Quantity); sut = sut.WithCapacity( reservedSeats + reservation.Quantity + excessCapacity); var actual = sut.TryAccept(reservations, reservation); Assert.Equal(new Maybe <Reservation>(reservation.Accept()), actual); }
public void TryAcceptReturnsNullOnInsufficientCapacity( Reservation reservation, IReadOnlyCollection <Reservation> reservations, int id, MaîtreD sut) { reservation.IsAccepted = false; var reservedSeats = reservations.Sum(r => r.Quantity); sut = sut.WithCapacity(reservedSeats + reservation.Quantity - 1); var actual = sut.TryAccept(reservation); Assert.True( actual.Accept(new StubReservationsVisitor <IMaybe <int> >(true, reservations, id)).IsNothing()); Assert.False(reservation.IsAccepted); }
public void TryAcceptReturnsNullOnInsufficientCapacity( Reservation reservation, IReadOnlyCollection <Reservation> reservations, int id, MaîtreD sut) { reservation.IsAccepted = false; var reservedSeats = reservations.Sum(r => r.Quantity); sut = sut.WithCapacity(reservedSeats + reservation.Quantity - 1); var actual = sut.TryAccept(reservation); Assert.Null( actual.Run(new StubReservationsHandler(true, reservations, id)).Result); Assert.False(reservation.IsAccepted); }
public void TryAcceptReturnsReservationIdInHappyPathScenario( Reservation reservation, IReadOnlyCollection <Reservation> reservations, MaîtreD sut, int excessCapacity, int expected) { var reservedSeats = reservations.Sum(r => r.Quantity); reservation.IsAccepted = false; sut = sut.WithCapacity( reservedSeats + reservation.Quantity + excessCapacity); var actual = sut.TryAccept(reservation); Assert.Equal( new Just <int>(expected), actual.Accept(new StubReservationsVisitor <IMaybe <int> >(true, reservations, expected))); Assert.True(reservation.IsAccepted); }