Exemplo n.º 1
0
        public void Outputter_Setup()
        {
            _uutOutputter = new AirTrafficOutputter();
            _airspace     = FakeAirspaceGenerator.GetAirspace(100, 100, 100);

            _logFile = "../../Test.txt";
        }
        public void DetectCondition_ConditionNotFound_EventHandlerNotInvoked()
        {
            bool       invoked     = false;
            ITrack     firstTrack  = FakeTrackFactory.GetTrack(1000, 1000, 1000);
            ITrack     secondTrack = FakeTrackFactory.GetTrack(1100, 1100, 1000);
            ITrackable airspace    = FakeAirspaceGenerator.GetAirspace(0, 0, 0);

            airspace.Trackables = new List <ITrack>()
            {
                firstTrack, secondTrack
            };
            _fakeCondition.ConditionBetween(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(false);
            _uutConditionDetector.ConditionsHandler += (s, e) => invoked = true;

            _uutConditionDetector.DetectCondition(airspace);

            Assert.That(invoked == false);
        }
        public void DetectCondition_ConditionFound_SecondConditionCorrect()
        {
            ConditionEventArgs eventArgsReceived = null;
            ITrack             firstTrack        = FakeTrackFactory.GetTrack(1000, 1000, 1000);
            ITrack             secondTrack       = FakeTrackFactory.GetTrack(1100, 1100, 1000);
            ITrackable         airspace          = FakeAirspaceGenerator.GetAirspace(0, 0, 0);

            airspace.Trackables = new List <ITrack>()
            {
                firstTrack, secondTrack
            };
            _fakeCondition.ConditionBetween(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(true);
            _uutConditionDetector.ConditionsHandler += (s, e) => eventArgsReceived = e;

            _uutConditionDetector.DetectCondition(airspace);

            Assert.That(eventArgsReceived.SecondConditionHolder, Is.EqualTo(secondTrack));
        }
        public void DetectCondition_MultipleConditions_EventHandlerInvokedCorrect(int numConditions)
        {
            int        timesInvoked    = 0;
            ITrack     trackInAirspace = FakeTrackFactory.GetTrack(1000, 1000, 1000);
            ITrackable airspace        = FakeAirspaceGenerator.GetAirspace(0, 0, 0);

            airspace.Trackables.Add(trackInAirspace); //There must be one track always
            for (int i = 0; i < numConditions; i++)
            {
                airspace.Trackables.Add(trackInAirspace);
            }
            //Because each element in the airspace is compared to each other:
            int expectedVisitations = numConditions * airspace.Trackables.Count / 2;

            _fakeCondition.ConditionBetween(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(true);
            _uutConditionDetector.ConditionsHandler += (s, e) => ++ timesInvoked;

            _uutConditionDetector.DetectCondition(airspace);

            Assert.That(timesInvoked, Is.EqualTo(expectedVisitations));
        }