public AirspaceManager(IFlightTrackManager datasource, IAirspaceArea airspaceArea) { _airspaceArea = airspaceArea; _content = new List <IFlightTrack>(); _dataSource = datasource; _dataSource.FlightTracksUpdated += OnFlightTracksUpdated; }
public void SetUp() { _dataSource = Substitute.For <IFlightTrackManager>(); _area = Substitute.For <IAirspaceArea>(); _airspaceManager = new AirspaceManager(_dataSource, _area); _enterExitEventDetector = new EnterExitEventDetector(_airspaceManager); _uut = new EnterExitEventController(_enterExitEventDetector); _dataSource.FlightTracksUpdated += (o, args) => _inputEventCounter++; _uut.EnterExitEventsUpdated += (o, args) => { _lastReceivedEnterExitEvents = args.ActiveEvents; _outputEventCounter++; }; _flight1 = Substitute.For <IFlightTrack>(); _flight2 = Substitute.For <IFlightTrack>(); _flight1.GetTag().Returns("TAG123"); _flight1.GetLastUpdatedAt().Returns(DateTime.Now); _flight2.GetTag().Returns("TAG456"); _flight2.GetLastUpdatedAt().Returns(DateTime.Now); //Use IAirspaceArea substitute to manually emulate flight airspace filtering (alt = 1 inside, alt = 0 outside) _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); }
public string GenerateAirspaceGrid(List <IFlightTrack> flights) { string airspacegrid = ""; var dps = new List <FTDataPoint>(); flights.ForEach(f => dps.Add(f.GetNewestDataPoint())); //empty grid char[,] grid = new char[grid_heigth, grid_width]; for (int i = 0; i < grid_heigth; i++) { for (int j = 0; j < grid_width; j++) { grid[i, j] = ' '; } } //x at flightpositions IAirspaceArea aa = _airspace.GetAirspaceArea(); //float width = aa.NorthEastCornerX - aa.SouthWestCornerX; //float heigth = aa.NorthEastCornerY - aa.SouthWestCornerY; float width = aa.Width(); float heigth = aa.Heigth(); if (dps.Count > 0) { foreach (var dp in dps) { int x = (int)lerp(0, grid_width, ((dp.X - aa.GetSouthWestCorner().X) / width)); int y = (int)lerp(0, grid_heigth, ((dp.Y - aa.GetSouthWestCorner().Y) / heigth)); grid[grid_heigth - 1 - y, x] = 'X'; } } //grid to string + add border string line = ""; for (int i = 0; i < grid_width; i++) { line += "-"; } line = "+" + line + "+\n"; airspacegrid += line; for (int i = 0; i < grid_heigth; i++) { airspacegrid += "|"; for (int j = 0; j < grid_width; j++) { airspacegrid += grid[i, j]; } airspacegrid += "|\n"; } airspacegrid += line; return(airspacegrid); }
public void SetUp() { //Event Counters _flightTracksUpdatedEventCount = 0; _airspaceUpdatedEventCount = 0; //Dependencies _datasource = Substitute.For <IFlightTrackManager>(); _datasource.FlightTracksUpdated += (sender, args) => _flightTracksUpdatedEventCount++; _area = Substitute.For <IAirspaceArea>(); _uut = new AirspaceManager(_datasource, _area); _uut.AirspaceContentUpdated += (sender, args) => { _airspaceUpdatedEventCount++; _airspaceUpdatedEventContent = args.AirspaceContent; }; _flight1 = Substitute.For <IFlightTrack>(); _flight2 = Substitute.For <IFlightTrack>(); }
public void Setup() { //Setup for constructor test _uut = new AirspaceArea(10000, 15000, 90000, 95000, 500, 20000); }