Esempio n. 1
0
        private void RelayEventHandler(object sender, TrackEventArgs e)
        {
            tracks = e.Tracks;
            tracks = _compassCourse.CalcCourse(tracks);
            tracks = _area.CheckArea(tracks);
            tracks = _speed.CalcSpeed(tracks);
            tracks = _conflict.DetectConflict(tracks);


            ControllerEvent(this, new TrackEventArgs()
            {
                Tracks = tracks
            });

            events = _eventDetector.DetectEvents(tracks);


            if (events != null && events.Count > 0)
            {
                DetectEvent(this, new EventEventArgs()
                {
                    Events = events
                });
            }
        }
Esempio n. 2
0
        public void SetUp()
        {
            _relay         = Substitute.For <IRelay>();
            _area          = Substitute.For <IArea>();
            _conflict      = Substitute.For <IConflict>();
            _speed         = Substitute.For <ISpeed>();
            _compasscourse = Substitute.For <ICompassCourse>();
            _eventdetector = Substitute.For <IEventDetector>();
            _relay         = Substitute.For <IRelay>();
            _results       = new TrackEventArgs();

            // Arbitrary List og tracks
            t = new List <Track>();
            t.Add(new Track("A", 500, DateTime.Now, new Position(1, 1)));

            // Make event on controller class with above made List<Track>
            args = new TrackEventArgs()
            {
                Tracks = t
            };

            // Make methods return data
            _compasscourse.CalcCourse(t).Returns(t);
            _area.CheckArea(t).Returns(t);
            _speed.CalcSpeed(t).Returns(t);
            _conflict.DetectConflict(t).Returns(t);

            // Make uut
            _uut = new Controller(_relay, _area, _compasscourse, _conflict, _speed, _eventdetector);

            // Make "fake" listener on Controller class, that has the TrackEventArgs, that can be Asserted on, also an event needs to have a listener to not break the code
            _uut.ControllerEvent += (sender, output) => _results = output;
        }
Esempio n. 3
0
        public void UutSetsTracksToOutOfArea(int x, int y, bool expectedResult)
        {
            List <Track> tracks = new List <Track>();

            tracks.Add(new Track("A1", 5000, DateTime.Now, new Position(x, y)));

            tracks = _uut.CheckArea(tracks);
            Assert.That(tracks[0].InArea, Is.EqualTo(expectedResult));
        }