Exemplo n.º 1
0
        public void ConditionHandler_ConditionInvoke_ConditionAdded()
        {
            var fakeFirstCondition     = FakeTrackFactory.GetTrackWithTag("firstCondition", 0, 0, 0);
            var fakeSecondCondition    = FakeTrackFactory.GetTrackWithTag("secondCondition", 0, 0, 0);
            var fakeConditionEventArgs = new ConditionEventArgs(fakeFirstCondition, fakeSecondCondition);

            _fakeConditionDetector.ConditionsHandler += Raise.EventWith(_fakeConditionDetector, fakeConditionEventArgs);

            Assert.That(_uutAirTrafficMonitor.Conditions.Contains(fakeConditionEventArgs));
        }
Exemplo n.º 2
0
        public void ConditionHandler_ConditionInvoke_LoggerInvokedCorrect()
        {
            var fakeFirstCondition     = FakeTrackFactory.GetTrackWithTag("firstCondition", 0, 0, 0);
            var fakeSecondCondition    = FakeTrackFactory.GetTrackWithTag("secondCondition", 0, 0, 0);
            var fakeConditionEventArgs = new ConditionEventArgs(fakeFirstCondition, fakeSecondCondition);

            _fakeConditionDetector.ConditionsHandler += Raise.EventWith(_fakeConditionDetector, fakeConditionEventArgs);

            _fakeOutputter.Logger.Received().LogCondition(
                Arg.Is <ITrack>(t => t == fakeFirstCondition),
                Arg.Is <ITrack>(t => t == fakeSecondCondition));
        }
Exemplo n.º 3
0
        public void Validate_AlreadyTracked_returnsFalse()
        {
            var track  = FakeTrackFactory.GetTrackWithTag("ATR424", 234, 432, 654);
            var track2 = FakeTrackFactory.GetTrackWithTag("ATR423", 200, 300, 400);

            _uut.Trackable = FakeAirspaceGenerator.GetAirspace(0, 0, 0);


            _uut.Trackable.Trackables.Add(track);

            var result = _uut.Validate(track2, _uut.Trackable);

            Assert.That(result, Is.EqualTo(false));
        }
Exemplo n.º 4
0
        public void IsTrackAlreadyRegistered_AlreadyTracked_returnsFalse()
        {
            var track  = FakeTrackFactory.GetTrackWithTag("ATR424", 234, 432, 654);
            var track2 = FakeTrackFactory.GetTrackWithTag("ATR423", 200, 300, 400);

            _uut.Trackable = FakeAirspaceGenerator.GetAirspace(0, 0, 0);


            _uut.Trackable.Trackables.Add(track);
            _uut.Trackable.Trackables.Add(track2);

            var result = _uut.IsTrackAlreadyRegistered(track, track2);

            Assert.That(result.Equals(false));
        }
Exemplo n.º 5
0
        public void Update_TheListIsUpdated_FirstTracksAreEqalSecondTracks()
        {
            List <ITrack> firstTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 100, 100, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 200, 200, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 200, 200, 400),
            };
            List <ITrack> secondTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 200, 300, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 100, 400, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 300, 500, 600),
            };

            _uutAirspaceUpdater.Update(ref firstTracks, secondTracks);

            CollectionAssert.AreEqual(firstTracks, secondTracks);
        }
        public void OnNewValidation_ValidateTracks_TrackAlreadyRegistered_EventHandlerInvoked()
        {
            var track1 = FakeTrackFactory.GetTrackWithTag("BCD123", 200, 300, 400);

            // pre-adds track to Airspace
            _validateTransponderData.Airspace.Trackables.Add(track1);

            // adds the same track to a list
            var tracksWithTags = new List <ITrack>()
            {
                track1
            };

            //This is the shared eventargs between Interpreter and Validator - now the TrackListEventArgs trackList also contains the same track
            var trackListEventArgs = new TrackListEventArgs(tracksWithTags);

            // by invoke, all "subscribers" are notified - in this case it is the ValidateTransponderData
            _trackListEvent.TrackListEventHandler += Raise.EventWith(_trackListEvent, trackListEventArgs);

            Assert.Contains(track1, _validationCompleteEventArgs.StillInAirspace);
        }
Exemplo n.º 7
0
        public void Update_SpeedNotSetIfTrackNotFound_SpeedIs0()
        {
            List <ITrack> firstTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 100, 100, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 200, 200, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 200, 200, 400),
            };
            List <ITrack> secondTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tagX", 200, 300, 100),
                FakeTrackFactory.GetTrackWithTag("tagY", 100, 400, 300),
                FakeTrackFactory.GetTrackWithTag("tagZ", 300, 500, 600),
            };

            _speedCalculator.Calculate(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(100);

            _uutAirspaceUpdater.Update(ref firstTracks, secondTracks);

            Assert.That(firstTracks.Select(track => track.Speed), Is.All.EqualTo(0).Within(1).Percent);
        }
Exemplo n.º 8
0
        public void Update_TheUpdateCalculatesCourse_CourseIsCorrect()
        {
            List <ITrack> firstTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 100, 100, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 200, 200, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 200, 200, 400),
            };
            List <ITrack> secondTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 200, 300, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 100, 400, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 300, 500, 600),
            };

            _courseCalculator.Calculate(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(100);

            _uutAirspaceUpdater.Update(ref firstTracks, secondTracks);

            Assert.That(firstTracks.Select(track => track.Course), Is.All.EqualTo(100.0).Within(1).Percent);
        }
Exemplo n.º 9
0
        public void Update_TrackPositionIsUpdated_TrackPositionCorrect(int newX, int newY, int newZ)
        {
            List <ITrack> firstTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 100, 100, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 200, 200, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 200, 200, 400),
            };
            List <ITrack> secondTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", newX, newY, newZ),
                FakeTrackFactory.GetTrackWithTag("tag2", newX, newY, newZ),
                FakeTrackFactory.GetTrackWithTag("tag3", newX, newY, newZ),
            };

            _uutAirspaceUpdater.Update(ref firstTracks, secondTracks);

            Assert.That(firstTracks.Select(track => track.TrackPosition.XCoordinate), Is.All.EqualTo(newX));
            Assert.That(firstTracks.Select(track => track.TrackPosition.YCoordinate), Is.All.EqualTo(newY));
            Assert.That(firstTracks.Select(track => track.TrackPosition.ZCoordinate), Is.All.EqualTo(newZ));
        }
Exemplo n.º 10
0
        public void Update_NewTrackConditionCheck_ConditionDetectorInvoked()
        {
            var fakeNewList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("newTrack", 0, 0, 0)
            };
            var fakeUpdateList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("updateTrack", 0, 0, 0)
            };
            var fakeRemoveList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("removeTrack", 0, 0, 0)
            };
            var fakeEventArgs = new ValidateEventArgs(fakeNewList, fakeRemoveList, fakeUpdateList);

            _fakeValidator.ValidationCompleteEventHandler += Raise.EventWith(_fakeValidator, fakeEventArgs);


            _fakeConditionDetector.Received().DetectCondition(Arg.Is <ITrackable>(trackList =>
                                                                                  trackList.Trackables.Exists(t => t.Tag == "newTrack")));
        }
Exemplo n.º 11
0
        public void Update_ValidationEventRaise_UpdaterInvoked()
        {
            var fakeNewList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("newTrack", 0, 0, 0)
            };
            var fakeUpdateList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("updateTrack", 0, 0, 0)
            };
            var fakeRemoveList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("removeTrack", 0, 0, 0)
            };
            var fakeEventArgs = new ValidateEventArgs(fakeNewList, fakeRemoveList, fakeUpdateList);

            _fakeValidator.ValidationCompleteEventHandler += Raise.EventWith(_fakeValidator, fakeEventArgs);


            _fakeUpdater.Received().Update(ref Arg.Any <List <ITrack> >(),
                                           Arg.Is <List <ITrack> >(trackList => trackList.Exists(t => t.Tag == "updateTrack")));
        }
Exemplo n.º 12
0
        public void Update_ValidationEventRaise_CorrectTracksRemoved()
        {
            var fakeNewList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("newTrack", 0, 0, 0)
            };
            var fakeUpdateList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("updateTrack", 0, 0, 0)
            };
            var fakeRemoveList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("removeTrack", 0, 0, 0)
            };

            _uutAirTrafficMonitor.Airspace.Trackables.Add(FakeTrackFactory.GetTrackWithTag("removeTrack", 120, 120, 120));
            var fakeEventArgs = new ValidateEventArgs(fakeNewList, fakeRemoveList, fakeUpdateList);

            _fakeValidator.ValidationCompleteEventHandler += Raise.EventWith(_fakeValidator, fakeEventArgs);


            Assert.That(_uutAirTrafficMonitor.Airspace.Trackables.Exists(t => t.Tag == "removeTrack"), Is.False);
        }
        public void OnNewValidation_ValidateTracks_NotInAirspaceAnymore_EventHandlerInvoked()
        {
            var track1 = FakeTrackFactory.GetTrackWithTag("BCD123", 200, 300, 400);

            // pre-adds track to Airspace
            _validateTransponderData.Airspace.Trackables.Add(track1);

            // these coordinates are not in airspace
            track1.TrackPosition.XCoordinate = -10;
            track1.TrackPosition.YCoordinate = -20;
            track1.TrackPosition.ZCoordinate = -30;

            // adds the same track with updated coordinates to a list
            var tracksWithTags = new List <ITrack>()
            {
                track1
            };

            //This is the shared eventargs between Interpreter and Validator - now the TrackListEventArgs trackList also contains the same track
            var trackListEventArgs = new TrackListEventArgs(tracksWithTags);

            // by invoke, all "subscribers" are notified - in this case it is the ValidateTransponderData
            _trackListEvent.TrackListEventHandler += Raise.EventWith(_trackListEvent, trackListEventArgs);

            /*_validationCompleteEventArgs.NotInAirspaceButUsedToBe.ForEach(track => Console.WriteLine(track.Tag + " " +
             *                                                                                       track.TrackPosition.XCoordinate + " " +
             *                                                                                       track.TrackPosition.YCoordinate + " " +
             *                                                                                       track.TrackPosition.ZCoordinate));*/

            /*_validationCompleteEventArgs.NotInAirspaceButUsedToBe.ForEach(track => Console.WriteLine(track.Tag));
             * _validationCompleteEventArgs.NewInAirspace.ForEach(track => Console.WriteLine(track.Tag));
             * _validationCompleteEventArgs.StillInAirspace.ForEach(track => Console.WriteLine(track.Tag));*/


            Assert.Contains(track1, _validationCompleteEventArgs.NotInAirspaceButUsedToBe);
        }