コード例 #1
0
        public Property CanAcceptReturnsReservationInHappyPathScenario()
        {
            return(Prop.ForAll((
                                   from rs in GenerateReservation.ListOf()
                                   from r in GenerateReservation
                                   from cs in Arb.Default.NonNegativeInt().Generator
                                   select(rs, r, cs.Item)).ToArbitrary(),
                               x =>
            {
                var(reservations, reservation, capacitySurplus) = x;
                var reservedSeats = reservations.Sum(r => r.Quantity);
                var capacity =
                    reservation.Quantity + reservedSeats + capacitySurplus;
                var sut = new MaîtreD(capacity);

                var actual = sut.CanAccept(reservations, reservation);

                Assert.True(actual);
            }));
        }
コード例 #2
0
        public Property CanAcceptOnInsufficientCapacity()
        {
            return(Prop.ForAll((
                                   from r in GenerateReservation
                                   from eq in Arb.Default.PositiveInt().Generator
                                   from cs in Arb.Default.NonNegativeInt().Generator
                                   from rs in GenerateReservation.ListOf()
                                   select(r, eq.Item, cs.Item, rs)).ToArbitrary(),
                               x =>
            {
                var(reservation, excessQuantity, capacitySurplus, reservations) = x;
                var reservedSeats = reservations.Sum(r => r.Quantity);
                var quantity = capacitySurplus + excessQuantity;
                var capacity = capacitySurplus + reservedSeats;
                reservation.Quantity = quantity;
                var sut = new MaîtreD(capacity);

                var actual = sut.CanAccept(reservations, reservation);

                Assert.False(actual);
            }));
        }