Пример #1
0
 public ControllerFactory(IDecoder decoder, ITrackDataFilter filter, ICollisionDetector collisionDetector, IDisplay display, ITransponderReceiver receiver, IFlightCalculator flightCalculator)
 {
     Decoder           = decoder;
     Filter            = filter;
     CollisionDetector = collisionDetector;
     Display           = display;
     Receiver          = receiver;
     FlightCalculator  = flightCalculator;
 }
Пример #2
0
 public ControllerFactory()
 {
     Decoder           = new Decoder();
     Filter            = new TrackDataFilter();
     CollisionDetector = new CollisionDetector(new Logger());
     Display           = new Display();
     Receiver          = TransponderReceiverFactory.CreateTransponderDataReceiver();
     FlightCalculator  =
         new FlightCalculator(new VelocityCalculator(), new DirectionCalculator());
 }
Пример #3
0
        public ATMController(ControllerFactory controllerFactory)
        {
            _decoder           = controllerFactory.Decoder;
            _filter            = controllerFactory.Filter;
            _flightCalculator  = controllerFactory.FlightCalculator;
            _collisionDetector = controllerFactory.CollisionDetector;
            _display           = controllerFactory.Display;
            _receiver          = controllerFactory.Receiver;

            _data = new Dictionary <string, FlightData>();

            _receiver.TransponderDataReady += OnTransponderDataReady;
        }
Пример #4
0
        public void Setup()
        {
            //Arrange
            _fakeDisplay           = Substitute.For <IDisplay>();
            _fakeTrackDataFilter   = Substitute.For <ITrackDataFilter>();
            _fakeFlightCalculator  = Substitute.For <IFlightCalculator>();
            _fakeCollisionDetector = Substitute.For <ICollisionDetector>();
            _fakeDecoder           = Substitute.For <IDecoder>();
            _fakeReceiver          = Substitute.For <ITransponderReceiver>();

            _fakeEventArgs      = new RawTransponderDataEventArgs(new List <string>());
            _fakeTrackData      = new List <TrackData>();
            _fakeFilteredData   = new List <TrackData>();
            _emptyFlightData    = new Dictionary <string, FlightData>();
            _fakeFlightData     = new Dictionary <string, FlightData>();
            _fakeCalculatedData = new Dictionary <string, FlightData>();
            _fakeSeperationData = new Tuple <List <string>, List <string> >(new List <string>(), new List <string>());

            //Fake decoder should return fake Trackdata when called with fakeEventArgs
            _fakeDecoder.Decode(_fakeEventArgs).Returns(_fakeTrackData);

            //Filter returns _fakeFilteredData
            _fakeTrackDataFilter.Filter(_fakeTrackData).Returns(_fakeFilteredData);

            //FlightCalculator returns _fakeFlightData
            _fakeFlightCalculator.Calculate(Arg.Any <Dictionary <string, FlightData> >(), Arg.Any <List <TrackData> >())
            .Returns(_fakeCalculatedData);

            //Seperation detector returns _fakeSeperationData
            _fakeCollisionDetector.SeperationCheck(Arg.Any <List <TrackData> >())
            .Returns(_fakeSeperationData);

            ControllerFactory fakeFactory = new ControllerFactory(
                _fakeDecoder,
                _fakeTrackDataFilter,
                _fakeCollisionDetector,
                _fakeDisplay,
                _fakeReceiver,
                _fakeFlightCalculator);

            _uut = new ATMController(fakeFactory);
        }