public void ReturnsExpectedProcessorForPassengerTypeEnum(PassengerType passengerType, Type expectedType) { _passengerProcessorProvider.GetProcessors().Returns(new Dictionary <PassengerType, IPassengerProcessor>() { { PassengerType.General, new GeneralPassengerProcessor() }, { PassengerType.LoyaltyMember, new LoyaltyMemberPassengerProcessor() }, { PassengerType.AirlineEmployee, new AirlineEmployeePassengerProcessor() }, { PassengerType.Discounted, new DiscountedPassengerProcessor() } }); var passengerProcessorFactory = new PassengerProcessorFactory(_passengerProcessorProvider); var processor = passengerProcessorFactory.GetProcessor(passengerType); processor.ShouldBeOfType(expectedType); }
public PassengerProcessorFactory(IPassengerProcessorsProvider passengerProcessorProvider) { _processors = passengerProcessorProvider.GetProcessors(); var passengerTypes = Enum.GetValues(typeof(PassengerType)).Cast <PassengerType>(); var registeredProcessorTypes = _processors.Keys.ToList(); var dif = passengerTypes.Except(registeredProcessorTypes).ToList(); if (dif.Any()) { throw new ArgumentException("Passenger type(s) without passenger processor implementations: " + string.Join(",", dif.Select(t => t.ToString()))); } }