[TestCase(0, 0, 1, 1, 315)] // North/East public void CompassCourseCalculatesCourseCorrectly(int x1, int y1, int x2, int y2, int expected) { List <Track> tracks = new List <Track>(); tracks.Add(new Track("trackA", 1000, DateTime.Now, new Position(x1, y1))); _Compasscourse.CalcCourse(tracks); tracks.Clear(); tracks.Add(new Track("trackA", 1000, DateTime.Now, new Position(x2, y2))); tracks = _Compasscourse.CalcCourse(tracks); Assert.AreEqual(expected, tracks[0].CompassCourse); }
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 }); } }
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; }