public ScheduledFlightSummary CalculateSummary(IEnumerable <Passenger> passengers, FlightRoute flightRoute) { var scheduledFlightSummary = new ScheduledFlightSummary(); foreach (var passenger in passengers) { scheduledFlightSummary.SeatsTaken++; scheduledFlightSummary.CostOfFlight += flightRoute.BaseCost; scheduledFlightSummary.SalesPerPassengerType[passenger.Type]++; var passengerProcessorContext = _passengerProcessorContextProvider.GetPassengerProcessorContext(passenger, flightRoute); var processor = _passengerProcessorFactory.GetProcessor(passenger.Type); var passengerFlightLogistics = processor.Process(passengerProcessorContext); scheduledFlightSummary.RevenueFromFlight += passengerFlightLogistics.ProfitFromFlight; scheduledFlightSummary.TotalLoyaltyPointsRedeemed += passengerFlightLogistics.LoyaltyPointsRedeemed; scheduledFlightSummary.TotalLoyaltyPointsAccrued += passengerFlightLogistics.LoyaltyPointsAccrued; scheduledFlightSummary.TotalExpectedBaggage += passengerFlightLogistics.ExpectedBaggage; } return(scheduledFlightSummary); }
public void SetUp() { _passengerProcessorFactory = Substitute.For <IPassengerProcessorFactory>(); _passengerProcessorContextProvider = Substitute.For <IPassengerProcessorContextProvider>(); _passengerProcessor = Substitute.For <IPassengerProcessor>(); var passengerFlightLogistics = AnyPassengerFlightLogistics(); _passengerProcessor.Process(Arg.Any <PassengerProcessorContext>()).Returns(passengerFlightLogistics); var passengerProcessorContext = new PassengerProcessorContext() { FlightRoute = FlightRoute, Passenger = new Passenger() }; _passengerProcessorContextProvider.GetPassengerProcessorContext(Arg.Any <Passenger>(), FlightRoute).Returns(passengerProcessorContext); _passengerProcessorFactory.GetProcessor(Arg.Any <PassengerType>()).Returns(_passengerProcessor); _scheduledFlightSummaryCalculator = new ScheduledFlightSummaryCalculator(_passengerProcessorFactory, _passengerProcessorContextProvider); }