コード例 #1
0
        //Run every time new data is present
        private void Update(RawTransponderDataEventArgs e)
        {
            //Decode Data
            List <TrackData> trackData = _decoder.Decode(e);

            //Filter data
            trackData = _filter.Filter(trackData);

            //Update existing flight data
            _data = _flightCalculator.Calculate(_data, trackData);

            //Collision Detect
            Tuple <List <string>, List <string> > collisionResult = _collisionDetector.SeperationCheck(trackData);
            List <string> collisionTags        = collisionResult.Item1;
            List <string> displayCollisionList = collisionResult.Item2;


            //Set CollisionFlag on flights
            foreach (KeyValuePair <string, FlightData> entry in _data)
            {
                entry.Value.CollisionFlag = collisionTags.Contains(entry.Value.Tag);
            }

            //Display Data
            _display.Clear();
            _display.Render(_data, displayCollisionList);
        }
コード例 #2
0
        public void FlightCalculatorCreateFlights()
        {
            Dictionary <String, FlightData> flightData = new Dictionary <String, FlightData>();
            TrackData track1 = new TrackData("test1", 10000, 10000, 5500, new DateTime());
            TrackData track2 = new TrackData("test2", 10000, 10000, 5500, new DateTime());

            List <TrackData> trackData = new List <TrackData> {
                track1, track2
            };

            uut.Calculate(flightData, trackData);
            flightData.TryGetValue("test1", out FlightData result);

            Assert.AreEqual(result.CurrentTrackData, track1);
            flightData.TryGetValue("test2", out result);
            Assert.AreEqual(result.CurrentTrackData, track2);
        }
コード例 #3
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);
        }
コード例 #4
0
        public void ATMController_EventIsRaised_DataIsPassedFromCalculatorAndCollisionDetectorToDisplay()
        {
            // Arrange
            _fakeEventArgs = new RawTransponderDataEventArgs(new List <string>());

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

            _fakeCalculatedData.Add(
                "AYE334", new FlightData(
                    new TrackData("AYE334", 12345, 54321, 5000, new DateTime(year: 2000, month: 10, day: 9, hour: 8, minute: 7, second: 6, millisecond: 5)))
                );

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



            _fakeSeperationData = Tuple.Create(
                new List <string>()
            {
                "AYO360", "HIW551"
            },
                new List <string>()
            {
                "Time of occurrence: 20190101010101010, Tags: AYO360, HIW551"
            }
                );

            _fakeCollisionDetector.SeperationCheck(Arg.Any <List <TrackData> >()).Returns(_fakeSeperationData);

            // Act
            _fakeReceiver.TransponderDataReady += Raise.EventWith(new object(), _fakeEventArgs);

            // Assert
            _fakeDisplay.Received().Render(Arg.Is <Dictionary <string, FlightData> >(x =>
                                                                                     x["AYE334"].Tag == "AYE334" && x["AYE334"].X == 12345 && x["AYE334"].Y == 54321 &&
                                                                                     x["AYE334"].Altitude == 5000 && x["AYE334"].Timestamp == new DateTime(2000, 10, 9, 8, 7, 6, 5)

                                                                                     ), Arg.Is <List <string> >(x =>
                                                                                                                x.Contains("Time of occurrence: 20190101010101010, Tags: AYO360, HIW551")
                                                                                                                ));
        }