public async Task ReservationSucceeds()
        {
            var repo = new FakeReservationsRepository();
            var sut  = new ReservationsController(10, repo);

            var reservation = new Reservation(
                date: new DateTimeOffset(2018, 8, 13, 16, 53, 0, TimeSpan.FromHours(2)),
                email: "*****@*****.**",
                name: "Mark Seemann",
                quantity: 4);
            var actual = await sut.Post(reservation);

            Assert.True(repo.Contains(reservation.Accept()));
            var expectedId = repo.GetId(reservation.Accept());
            var ok         = Assert.IsAssignableFrom <OkActionResult>(actual);

            Assert.Equal(expectedId, ok.Value);
        }
        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);
        }
Beispiel #3
0
 private void ReservationsGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (e.ColumnIndex == ReservationsGridView.Columns["AcceptButtonColumn"].Index)
         {
             Reservation reservation = (Reservation)ReservationsGridView.Rows[e.RowIndex].Cells[0].Value;
             reservation.Accept();
             RefreshReservations();
         }
         else if (e.ColumnIndex == ReservationsGridView.Columns["DeclineButtonColumn"].Index)
         {
             Reservation reservation = (Reservation)ReservationsGridView.Rows[e.RowIndex].Cells[0].Value;
             reservation.Decline();
             RefreshReservations();
         }
         else if (e.ColumnIndex == ReservationsGridView.Columns["MoreInfoButton"].Index)
         {
             Reservation reservation = (Reservation)ReservationsGridView.Rows[e.RowIndex].Cells[0].Value;
             reservation.ShowInfo();
         }
     }
 }