Example #1
0
        public void IsTrackZCoordinateInAirspaceArea_IsInAirspace_returnsFalse()
        {
            _uut.Track     = FakeTrackFactory.GetTrack(200, 300, 400);
            _uut.Trackable = FakeAirspaceGenerator.GetAirspace(1000, 1000, 1000);

            var result = _uut.IsTrackZCoordinateInAirspaceArea();

            Assert.That(result.Equals(false));
        }
Example #2
0
        public void IsTrackYCoordinateInAirspaceArea_IsInAirspace_returnsTrue()
        {
            _uut.Track     = FakeTrackFactory.GetTrack(200, 300, 400);
            _uut.Trackable = FakeAirspaceGenerator.GetAirspace(0, 0, 0);

            var result = _uut.IsTrackYCoordinateInAirspaceArea();

            Assert.That(result);
        }
Example #3
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));
        }
Example #4
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));
        }
        public void OnNewValidation_ValidateTracksReceived_NewInAirspace_EventHandlerInvoked()// airspace starts empty
        {
            var tracksWithTags = FakeTrackFactory.GetMultipleTracksWithTags(10);

            //This is the shared eventargs between Interpreter and Validator
            var trackListEventArgs = new TrackListEventArgs(tracksWithTags);

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


            CollectionAssert.AreEqual(tracksWithTags, _validationCompleteEventArgs.NewInAirspace);
        }
Example #6
0
        public void OnValidationComplete_Invoked()
        {
            var invoked = false;

            var trackList = FakeTrackFactory.GetMultipleTracksWithTags(1);

            _trackListEventArgs = new TrackListEventArgs(trackList);

            _uutValidateTransponderData.ValidationCompleteEventHandler += (sender, args) => invoked = true;

            _trackListEvent.TrackListEventHandler += Raise.EventWith(this, _trackListEventArgs);

            Assert.That(invoked);
        }
Example #7
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));
        }
        public void ValidateTransponderData_EventHandlerInvoked()
        {
            var invoked        = false;
            var tracksWithTags = FakeTrackFactory.GetMultipleTracksWithTags(10);

            //This is the shared eventargs between Interpreter and Validator
            var trackListEventArgs = new TrackListEventArgs(tracksWithTags);

            _trackListEvent.TrackListEventHandler += (sender, args) => invoked = true;

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

            Assert.True(invoked);
        }
Example #9
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));
        }
        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 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);
        }
        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);
        }
        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);
        }
        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));
        }
Example #15
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")));
        }
Example #16
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")));
        }
Example #17
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);
        }