示例#1
0
        public void SetUp()
        {
            _dataSource             = Substitute.For <IFlightTrackManager>();
            _area                   = Substitute.For <IAirspaceArea>();
            _airspaceManager        = new AirspaceManager(_dataSource, _area);
            _enterExitEventDetector = new EnterExitEventDetector(_airspaceManager);
            _uut = new EnterExitEventController(_enterExitEventDetector);

            _dataSource.FlightTracksUpdated += (o, args) => _inputEventCounter++;
            _uut.EnterExitEventsUpdated     += (o, args) =>
            {
                _lastReceivedEnterExitEvents = args.ActiveEvents;
                _outputEventCounter++;
            };

            _flight1 = Substitute.For <IFlightTrack>();
            _flight2 = Substitute.For <IFlightTrack>();
            _flight1.GetTag().Returns("TAG123");
            _flight1.GetLastUpdatedAt().Returns(DateTime.Now);
            _flight2.GetTag().Returns("TAG456");
            _flight2.GetLastUpdatedAt().Returns(DateTime.Now);

            //Use IAirspaceArea substitute to manually emulate flight airspace filtering (alt = 1 inside, alt = 0 outside)
            _area.IsInside(Arg.Any <int>(), Arg.Any <int>(), Arg.Is <int>(x => x == 1)).Returns(true);
            _area.IsInside(Arg.Any <int>(), Arg.Any <int>(), Arg.Is <int>(x => x == 0)).Returns(false);
        }
示例#2
0
        public void OnFlightTracksUpdated_OneFlightInAirspace_AirspaceUpdated_OneFlightInAirspace()
        {
            //Arrange
            _area.IsInside(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <int>()).Returns(true);
            var args = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> {
                _flight2
            });

            //Act
            _datasource.FlightTracksUpdated += Raise.EventWith(args);

            Assert.That(_airspaceUpdatedEventCount, Is.EqualTo(1));
            Assert.That(_airspaceUpdatedEventContent.Count, Is.EqualTo(1));
        }
示例#3
0
        private void OnFlightTracksUpdated(object o, FlightTracksUpdatedEventArgs args)
        {
            List <IFlightTrack> allUpdatedFlights = args.UpdatedFlights;

            _content.Clear();

            foreach (var f in allUpdatedFlights)
            {
                var pos = f.GetCurrentPosition();
                if (_airspaceArea.IsInside((int)pos.X, (int)pos.Y, (int)f.GetCurrentAltitude()))
                {
                    _content.Add(f);
                }
            }

            FlightTracksUpdated?.Invoke(this, new FlightTracksUpdatedEventArgs(_content));
            AirspaceContentUpdated?.Invoke(this, new AirspaceContentEventArgs(_content));
        }
示例#4
0
 public bool AirspaceArea_IsInside_TestCases(int x, int y, int altitude)
 {
     //Assert
     return(_uut.IsInside(x, y, altitude));
 }