public void AddDataPoint_GetCurrentAltitute_CorrectAltitude() { // Act _uut.AddDataPoint(_firstDataPoint); // Assert Assert.That(_uut.GetCurrentAltitude(), Is.EqualTo(_firstDataPoint.Altitude)); }
public void OnFlightTracksUpdated_FlightEnterAirspaceThenOtherFlightEnterNotInAirspace_OneEnterEvents() { //Arrange _flight1.GetCurrentAltitude().Returns(1d); //inside _flight2.GetCurrentAltitude().Returns(0d); //outside var args1 = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { }); var args2 = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { _flight1 }); var args3 = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { _flight1 }); var args4 = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { _flight1, _flight2 }); var args5 = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { _flight1, _flight2 }); //Act _dataSource.FlightTracksUpdated += Raise.EventWith(args1); _dataSource.FlightTracksUpdated += Raise.EventWith(args2); _dataSource.FlightTracksUpdated += Raise.EventWith(args3); _dataSource.FlightTracksUpdated += Raise.EventWith(args4); _dataSource.FlightTracksUpdated += Raise.EventWith(args5); //Assert Assert.That(_lastReceivedEnterExitEvents.Count, Is.EqualTo(1)); Assert.That(_lastReceivedEnterExitEvents.Where(e => e.Entered).Count, Is.EqualTo(1)); Assert.That(_lastReceivedEnterExitEvents.Where(e => !e.Entered).Count, Is.EqualTo(0)); }
public void OnFlightUpdatedSeperationEventDetect_TwoFlightsSeperate_TwoEnterOneEvent() { _flight1a.GetCurrentPosition().Returns(new Vector2(5000, 7050)); _flight1b.GetCurrentPosition().Returns(new Vector2(5000, 6960)); _flight1c.GetCurrentPosition().Returns(new Vector2(5000, 6850)); _flight2a.GetCurrentPosition().Returns(new Vector2(5000, 2000)); _flight2b.GetCurrentPosition().Returns(new Vector2(5000, 2100)); _flight2c.GetCurrentPosition().Returns(new Vector2(5000, 2200)); _flight1a.GetCurrentAltitude().Returns(700); _flight1b.GetCurrentAltitude().Returns(700); _flight1c.GetCurrentAltitude().Returns(700); _flight2a.GetCurrentAltitude().Returns(600); _flight2b.GetCurrentAltitude().Returns(600); _flight2c.GetCurrentAltitude().Returns(600); var args1 = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { _flight1a, _flight2a }); //Far enough var args2 = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { _flight1b, _flight2b }); //too close //var args3 = new FlightTracksUpdatedEventArgs(new List<IFlightTrack> { _flight1c, _flight2c }); //still too close //Act _datasource.FlightTracksUpdated += Raise.EventWith(args1); _datasource.FlightTracksUpdated += Raise.EventWith(args2); //_datasource.FlightTracksUpdated += Raise.EventWith(args3); Assert.That(_SeperationEventCount, Is.EqualTo(1)); Assert.That(_flightTracksUpdatedCounter, Is.EqualTo(2)); }
public bool TracksConflicting(IFlightTrack f1, IFlightTrack f2) { double f1alt = f1.GetCurrentAltitude(); double f2alt = f2.GetCurrentAltitude(); Vector2 f1pos = f1.GetCurrentPosition(); Vector2 f2pos = f2.GetCurrentPosition(); if ((Math.Abs(f1alt - f2alt) < _altitude) && Vector2.Distance(f1pos, f2pos) < _distance) { return(true); } else { return(false); } }
public void OnFlightTracksUpdated_OneFlightInAirspaceOnFlightOutsideAirspace_AirspaceUpdated_OneFlightInAirspace() { //Arrange _flight1.GetCurrentAltitude().Returns(1d); _flight2.GetCurrentAltitude().Returns(0d); _area.IsInside(Arg.Any <int>(), Arg.Any <int>(), Arg.Is <int>(x => x == 1)).Returns(true); _area.IsInside(Arg.Any <int>(), Arg.Any <int>(), Arg.Is <int>(x => x == 0)).Returns(false); var args = new FlightTracksUpdatedEventArgs(new List <IFlightTrack> { _flight1, _flight2 }); //Act _datasource.FlightTracksUpdated += Raise.EventWith(args); //Assert Assert.That(_airspaceUpdatedEventCount, Is.EqualTo(1)); Assert.That(_airspaceUpdatedEventContent.Count, Is.EqualTo(1)); }