Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string isRepeat = string.Empty;

            do
            {
                try
                {
                    Console.WriteLine("Please select the search Categary:");
                    Console.WriteLine("0. Print all flights");
                    Console.WriteLine("1. Depart before the current date/time.");
                    Console.WriteLine("2. Have a segment with an arrival date before the departure date.");
                    Console.WriteLine("3. Spend more than [X] hours on the ground.");
                    Console.WriteLine("Press e for end");
                    Console.WriteLine("--------------------------------------------------------------");

                    MyDependancyResolver myDependancyResolver = new MyDependancyResolver();
                    IFlightBuilder       flightBuilder        = (IFlightBuilder)myDependancyResolver.GetConcreteClass(typeof(IFlightBuilder));
                    IFlightFilter        flightFilter         = null;
                    IList <Flight>       flight = null;

                    string input = Console.ReadLine();
                    switch (input)
                    {
                    case "3":
                    case "2":
                    case "1":
                    case "0":
                        flightFilter = myDependancyResolver.GetFlightFilterImplementation(input, flightBuilder);
                        if (flightFilter.ParameterCount > 0)
                        {
                            Console.WriteLine("X value:");
                            flightFilter.ParameterArray = new object[] { Console.ReadLine() };
                        }
                        break;

                    case "e":
                        isRepeat = "true";
                        break;

                    default:
                        Console.WriteLine(ValidationString);
                        break;
                    }
                    if (flightFilter != null)
                    {
                        flight = flightFilter.GetFilterResult();
                        IFlightPrinter printFlight = (IFlightPrinter)myDependancyResolver.GetConcreteClass(typeof(IFlightPrinter));
                        printFlight.PrintFlights(flight);
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine(SearchAgainString);
                    isRepeat = "true";
                    continue;
                }
            } while (string.IsNullOrEmpty(isRepeat));
        }
Exemplo n.º 2
0
 public FlightService(IFlightBuilder flightBuilder)
 {
     _flightBuilder = flightBuilder;
     _flights       = _flightBuilder.GetFlights()?
                      .EnforceSegmentsOrderByDeparture()
                      .RemoveEmptyFligths()
                      .ToList();
 }
Exemplo n.º 3
0
 public FlightBuilderWrapper(IFlightBuilder _flightBuilder)
 {
     if (_flightBuilder == null)
     {
         throw new ArgumentNullException(nameof(_flightBuilder));
     }
     this._flightBuilder = _flightBuilder;
 }
Exemplo n.º 4
0
 public Startup(
     IHostApplicationLifetime lifeTime,
     ILogger <Startup> log,
     IFilterService filterService,
     IFlightBuilder flightBuilder)
 {
     _lifeTime      = lifeTime;
     _log           = log;
     _filterService = filterService;
     _flightBuilder = flightBuilder;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Depending on the filterCategory string value, provides the implementation for IFlightFilter interfce
        /// </summary>
        /// <param name="filterCategoty">FilterCategory string </param>
        /// <returns>object implementing the IFlightFilter interface</returns>
        public IFlightFilter GetFlightFilterImplementation(string filterCategoty, IFlightBuilder flightBuilder)
        {
            IFlightFilter flightFilter = null;

            switch (filterCategoty)
            {
            case "0":
                flightFilter = (IFlightFilter)Activator.CreateInstance(typeof(FlightFilter), flightBuilder);
                break;

            case "1":
                flightFilter = (IFlightFilter)Activator.CreateInstance(typeof(FlightFilter1), flightBuilder);
                break;

            case "2":
                flightFilter = (IFlightFilter)Activator.CreateInstance(typeof(FlightFilter2), flightBuilder);
                break;

            case "3":
                flightFilter = (IFlightFilter)Activator.CreateInstance(typeof(FlightFilter3), flightBuilder);
                break;
            }
            return(flightFilter);
        }
Exemplo n.º 6
0
 public FlightService(IFlightBuilder pservice)
 {
     service = pservice;
 }
        public void Init()
        {
            _flightBuilder = MockRepository.GenerateMock <IFlightBuilder>();

            _flightBooker = new FlightBuilderWrapper(_flightBuilder);
        }
Exemplo n.º 8
0
 public FlightController(IFlightBuilder flightBuilder)
 {
     _flightBuider = flightBuilder;
 }
Exemplo n.º 9
0
 public FlightsController(IFlightFilterRulesService rulesService,
     IFlightBuilder flightBuilder)
 {
     _rulesService = rulesService;
     _flightBuilder = flightBuilder;
 }
 public void SetUp()
 {
     _builder = A.Fake<IFlightBuilder>();
     _rulesService = A.Fake<IFlightFilterRulesService>();
     A.CallTo(() => _rulesService.GetRules()).Returns(SomeRules());
 }
Exemplo n.º 11
0
 public FlightFilter2(IFlightBuilder flightBuilder) : base(flightBuilder)
 {
 }
Exemplo n.º 12
0
 public FlightFilter(IFlightBuilder flightBuilder)
 {
     this.flightBuilder = flightBuilder;
 }
Exemplo n.º 13
0
 public FlightFilter3(IFlightBuilder flightBuilder) : base(flightBuilder)
 {
     _parameterCount = 1;
 }
Exemplo n.º 14
0
 public Worker(WorkerNestedTypesFactory workerNestedTypesFactory)
 {
     _flightBuilder = workerNestedTypesFactory.GetFlightBuilder();
     _filterBuilder = workerNestedTypesFactory.GetFilterBuilder();
     _filterHandler = workerNestedTypesFactory.GetFilterHandler();
 }
Exemplo n.º 15
0
 public FlightService(IFlightBuilder flightBuilder, IDateTimeService dateTimeService)
 {
     _flightBuilder   = flightBuilder;
     _dateTimeService = dateTimeService;
 }
Exemplo n.º 16
0
 /* Constructor. */
 public FlightCreator(IFlightBuilder builder)
 {
     this.flightBuilder = builder;
 }
Exemplo n.º 17
0
 public void Init()
 {
     flightBuilderOperations = new FlightBuilderOperations();
     flightBuilder           = new FlightBuilder();
     _twoDaysFromNow         = DateTime.Now.AddDays(2);
 }