public void Should_be_a_value_type() { var firstInstance = new CoachSnapshot("A-train", TrainProviderHelper.GetSeatsWithBookingReferencesFor1CoachesOf10SeatsAnd6ReservedSeats()); var secondInstance = new CoachSnapshot("A-train", TrainProviderHelper.GetSeatsWithBookingReferencesFor1CoachesOf10SeatsAnd6ReservedSeats()); Check.That(firstInstance).IsEqualTo(secondInstance); }
public void Should_say_it_has_enough_available_seats_when_below_70_percent_of_its_capacity() { var coach = new CoachSnapshot("A-train", TrainProviderHelper.GetSeatsWithBookingReferencesFor1CoachesOf10SeatsAnd6ReservedSeats()); var ask1Seat = 1; Check.That(coach.HasEnoughAvailableSeatsIfWeFollowTheIdealPolicy(ask1Seat)).IsTrue(); var ask2Seats = 2; Check.That(coach.HasEnoughAvailableSeatsIfWeFollowTheIdealPolicy(ask2Seats)).IsFalse(); }
public static Dictionary <string, CoachSnapshot> InstantiateCoaches(string trainId, IEnumerable <SeatWithBookingReference> seatsWithBookingReferences) { var result = new Dictionary <string, CoachSnapshot>(); var coachNames = (from sbr in seatsWithBookingReferences select sbr.Seat.Coach).Distinct(); foreach (var coachName in coachNames) { var seatsForThisCoach = from sbr in seatsWithBookingReferences where sbr.Seat.Coach == coachName select sbr; var coach = new CoachSnapshot(trainId, new List <SeatWithBookingReference>(seatsForThisCoach)); result[coachName] = coach; } return(result); }