public void VelocityCalculatorSameDataReturns0()
        {
            TrackData dummyTrackData1 = new TrackData(dummyTag, dummyX, dummyY, dummyAltitude, dummyTimestamp);
            TrackData dummyTrackData2 = new TrackData(dummyTag, dummyX, dummyY, dummyAltitude, dummyTimestamp2);

            Assert.AreEqual(0, uut.CalculateSpeed(dummyTrackData1, dummyTrackData2));
        }
예제 #2
0
        public Dictionary <string, FlightData> Calculate(Dictionary <String, FlightData> flightData, List <TrackData> trackData)
        {
            foreach (TrackData track in trackData)
            {
                if (flightData.TryGetValue(track.Tag, out FlightData flight))
                {
                    flight.Velocity         = _velocityCalculator.CalculateSpeed(flight.CurrentTrackData, track);
                    flight.CompassCourse    = _directionCalculator.CalculateDirection(flight.CurrentTrackData, track);
                    flight.CurrentTrackData = track;
                }
                else
                {
                    flightData.Add(track.Tag, new FlightData(track));
                }
            }

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

            foreach (KeyValuePair <string, FlightData> entry in flightData)
            {
                if (trackData.Contains(entry.Value.CurrentTrackData))
                {
                    newFlightData.Add(entry.Key, entry.Value);
                }
            }
            return(newFlightData);
        }
예제 #3
0
        public void Setup()
        {
            _fakeVelocityCalculator  = Substitute.For <IVelocityCalculator>();
            _fakeDirectionCalculator = Substitute.For <IDirectionCalculator>();
            _fakeCollisionDetector   = Substitute.For <ICollisionDetector>();

            _fakeVelocityCalculator.CalculateSpeed(Arg.Any <TrackData>(), Arg.Any <TrackData>()).Returns(1000);
            _fakeDirectionCalculator.CalculateDirection(Arg.Any <TrackData>(), Arg.Any <TrackData>()).Returns(45);


            uut = new FlightCalculator(_fakeVelocityCalculator, _fakeDirectionCalculator);
        }