Exemple #1
0
        [TestCase(20000, 10000, 1000)] //z high
        public void TestWithinBounds_TrackWithinBounds_ReturnsTrue(int x, int y, int z)
        {
            var track = Substitute.For <ITrack>();

            track.XPos     = x;
            track.YPos     = y;
            track.Altitude = z;

            Assert.That(_uut.IsWithinBounds(track), Is.EqualTo(true));
        }
Exemple #2
0
        public void Setup()
        {
            _airspace = Substitute.For <IAirspace>();
            _uut      = new TrackManager();

            _trackInside       = Substitute.For <ITrack>();
            _trackInside.Tag   = "1";
            _trackInside.YPos  = 10;
            _trackOutside      = Substitute.For <ITrack>();
            _trackOutside.Tag  = "1";
            _trackOutside.YPos = 24000;

            _airspace.IsWithinBounds(Arg.Is(_trackInside)).Returns(true);
            _airspace.IsWithinBounds(Arg.Is(_trackOutside)).Returns(false);
        }
Exemple #3
0
        public void testHandleTrack_TrackMovesWithinAirspace_ChangePositionCalled()
        {
            var called = false;

            _trackInside.When(x => x.ChangePosition(Arg.Any <float>(), Arg.Any <float>(), Arg.Any <float>(), Arg.Any <DateTime>())).Do(x => called = true);

            ITrack track2 = Substitute.For <ITrack>();

            track2.Tag  = "1";
            track2.YPos = 24000;

            _airspace.IsWithinBounds(Arg.Is(track2)).Returns(true);

            _uut.HandleTrack(_trackInside, _airspace);
            _uut.HandleTrack(track2, _airspace);

            Assert.That(_uut.Tracks.Count, Is.EqualTo(1));
            Assert.That(called, Is.EqualTo(true));
        }
Exemple #4
0
        public void HandleTrack(ITrack track, IAirspace airspace)
        {
            bool check = true;                                                                     //bool to make a check after list loop

            if (airspace.IsWithinBounds(track))                                                    // check if within bounds
            {
                foreach (var t in tracks)                                                          //loop through list
                {
                    if (t.Tag == track.Tag)                                                        //compare new track tag to tracks already known
                    {
                        t.ChangePosition(track.XPos, track.YPos, track.Altitude, track.Timestamp); //known tag, change position

                        check = false;
                        OnRaiseTrackUpdatedEvent(new TracksUpdatedEventArgs(tracks.ToList(), track));
                        break;
                    }
                }
                if (check)
                {
                    tracks.Add(track); //new tag, just add it
                    OnRaiseEntryDetectedEvent(new TracksUpdatedEventArgs(tracks.ToList(), track));
                    OnRaiseTrackUpdatedEvent(new TracksUpdatedEventArgs(tracks.ToList(), track));
                }
            }
            else // remember to compare tag with tags already in our list, so we can remove old tracks
            {
                foreach (var t in tracks)
                {
                    if (t.Tag == track.Tag)
                    {
                        tracks.Remove(t);
                        OnRaiseExitDetectedEvent(new TracksUpdatedEventArgs(tracks.ToList(), track));
                        OnRaiseTrackUpdatedEvent(new TracksUpdatedEventArgs(tracks.ToList(), track));
                        return;
                    }
                }
            }
            OnRaiseTrackUpdatedEvent(new TracksUpdatedEventArgs(tracks.ToList(), track));
        }