Last active
March 31, 2020 01:03
-
-
Save yowchun93/e374185db82e9e8876ca6c3d845e741d to your computer and use it in GitHub Desktop.
Restaurant Reservations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void TryAcceptReturnsReservationIdInHappyPathScenario( | |
[Frozen]Mock<IReservationsRepository> td, | |
Reservation reservation, | |
IReadOnlyCollection<Reservation> reservations, | |
MaîtreD sut, | |
int excessCapacity, | |
int expected) | |
{ | |
// i think td refers to test-double | |
// ReservationsRepository is mocked | |
td.Setup(r => r.IsReservationInFuture(reservation)).Returns(true); | |
td | |
.Setup(r => r.ReadReservations(reservation.Date)) | |
.Returns(reservations); | |
td.Setup(r => r.Create(reservation)).Returns(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(expected, actual); | |
Assert.True(reservation.IsAccepted); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment