public void HandleTrackOutsideAirspace_TrackExistsInNewestTracks_TrackWasRemoved() { //Arrange //Adding elements to private lists inside flightmanagement for (int i = 0; i < 10; i++) { TrackEventArgs e = new TrackEventArgs(new Track() { Tag = "FlightNo " + i }); _flightManagement.HandleTrackInsideAirspace(this, e); } //Creating the track that should be removed: Track track = new Track() { Tag = "FlightNo 0" }; TrackEventArgs arg = new TrackEventArgs(track); //Creating a list that will be copied upon calling HandleTrackInsideAirspace. List <Track> newestTracks = new List <Track>(); _flightManagement.FlightDataReady += (sender, args) => newestTracks = args.NewestTracks; //Act _flightManagement.HandleTrackOutsideAirspace(this, arg); //Assert //Copying private list with newests tracks that will be asserted on _flightManagement.HandleTrackInsideAirspace(this, new TrackEventArgs(new Track())); Assert.That(newestTracks.Count(p => p.Tag == track.Tag), Is.EqualTo(0)); }
public void HandleTrackInsideAirpsace_TracksAreColliding_TracksAreLogged(int altitude1, int altitude2, double x1, double x2, double y1, double y2) { Track trackOne = new Track() { Tag = "ASE2018", Altitude = altitude1, XCoordinate = x1, YCoordinate = y2 }; Track trackTwo = new Track() { Tag = "CAP0805", Altitude = altitude1, XCoordinate = x1, YCoordinate = y2 }; _flightManagement.HandleTrackInsideAirspace(this, new TrackEventArgs(trackOne)); _flightManagement.HandleTrackInsideAirspace(this, new TrackEventArgs(trackTwo)); _fakeFileWriter.WriteToFile("", Arg.Is <string>(s => s.Contains("ASE2018") && s.Contains("CAP0805"))); }
public void HandleTrackInsideAirspace_TrackDoesNotExistInNewestList_TrackWasAddedToNewestList() { Track track = new Track() { Tag = "FlightNo 0" }; TrackEventArgs arg = new TrackEventArgs(track); List <Track> newestTracks = new List <Track>(); _flightManagement.FlightDataReady += (sender, args) => newestTracks = args.NewestTracks; //Act _flightManagement.HandleTrackInsideAirspace(this, arg); Assert.That(newestTracks.Count(p => p.Tag == track.Tag), Is.EqualTo(1)); }
public void HandleTracksInsideAirspace_TracksGetAnalyzed_TrackDataIsCorrect(int secondsBetweenTimestamps, double x1, double x2, double y1, double y2, double expectedVelocity, double expectedCourse) { DateTime firstTimeStamp = DateTime.Now; DateTime secondTimeStamp = firstTimeStamp.AddSeconds(secondsBetweenTimestamps); Track firstTrack = new Track() { Tag = "ASE2018", Altitude = 300, XCoordinate = x1, YCoordinate = y1, TimeStamp = firstTimeStamp }; Track secondTrack = new Track() { Tag = "ASE2018", Altitude = 300, XCoordinate = x2, YCoordinate = y2, TimeStamp = secondTimeStamp }; string log = ""; _flightAnalyzer.TracksAnalyzedEvent += (sender, args) => log = args.Log; _flightManagement.HandleTrackInsideAirspace(this, new TrackEventArgs(firstTrack)); _flightManagement.HandleTrackInsideAirspace(this, new TrackEventArgs(secondTrack)); string expectedString = "Tag: " + secondTrack.Tag + " X: " + secondTrack.XCoordinate + " Y: " + secondTrack.YCoordinate + " Altitude: " + secondTrack.Altitude + " Velocity: " + expectedVelocity + " Course: " + expectedCourse + " Time stamp: " + secondTimeStamp.ToString(); Assert.That(log, Is.EqualTo(expectedString)); }