public void ParseData(AbstractSectorDataFile data) { foreach (SectorData line in data) { if (line.dataSegments.Count != 4) { eventLogger.AddEvent(new SyntaxError("Invalid number of runway centreline segments", line)); return; } if (!CoordinateParser.TryParse(line.dataSegments[0], line.dataSegments[1], out Coordinate firstCoordinate)) { eventLogger.AddEvent(new SyntaxError("Invalid first runway centreline coordinate", line)); return; } if (!CoordinateParser.TryParse(line.dataSegments[2], line.dataSegments[3], out Coordinate secondCoordinate)) { eventLogger.AddEvent(new SyntaxError("Invalid second runway centreline coordinate", line)); return; } // Create the segment once and share it to save memory RunwayCentrelineSegment segment = new(firstCoordinate, secondCoordinate); sectorElements.Add(new RunwayCentreline(segment, line.definition, line.docblock, line.inlineComment)); sectorElements.Add(new FixedColourRunwayCentreline(segment, line.definition, line.docblock, line.inlineComment)); } }
public static void InjectAdjacentAirportsData(SectorElementCollection collection) { // Add airport collection.Add( new Airport( "Show adjacent departure airports", "000A", new Coordinate("S999.00.00.000", "E999.00.00.000"), "199.998", new Definition("Defined by compiler", 0), new Docblock(), new Comment("") ) ); // Add runway collection.Add( new Runway( "000A", "00", 0, new Coordinate("S999.00.00.000", "E999.00.00.000"), "01", 0, new Coordinate("S999.00.00.000", "E999.00.00.000"), new Definition("Defined by compiler", 0), new Docblock(), new Comment("") ) ); }
public RoutePointValidatorTest() { sectorElements = new SectorElementCollection(); sectorElements.Add(FixFactory.Make("testfix")); sectorElements.Add(VorFactory.Make("testvor")); sectorElements.Add(NdbFactory.Make("testndb")); sectorElements.Add(AirportFactory.Make("testairport")); }
public AllSectorsMustHaveValidBorderTest() { sectorElements = new SectorElementCollection(); loggerMock = new Mock <IEventLogger>(); rule = new AllSectorsMustHaveValidBorder(); args = new CompilerArguments(); sectorElements.Add(SectorlineFactory.Make("ONE")); sectorElements.Add(SectorlineFactory.Make("TWO")); sectorElements.Add(CircleSectorlineFactory.Make("THREE")); }
public void ParseData(AbstractSectorDataFile data) { List <HeaderLine> lines = new List <HeaderLine>(); foreach (SectorData line in data) { if (line.dataSegments.Count != 0) { this.errorLog.AddEvent( new SyntaxError("Cannot define data in file headers", line) ); continue; } lines.Add( new HeaderLine( line.inlineComment, line.definition ) ); } sectorElements.Add( new Header( new Definition(data.FullPath, 0), lines ) ); }
public void ParseData(AbstractSectorDataFile data) { foreach (SectorData line in data) { if (line.dataSegments.Count != 3) { this.errorLog.AddEvent( new SyntaxError("Invalid number of colour definition segments", line) ); continue; } if (line.dataSegments[0] != "#define") { this.errorLog.AddEvent( new SyntaxError("Colour definitions must begin with #define", line) ); continue; } if (!int.TryParse(line.dataSegments[2].Trim(), out int colourValue)) { this.errorLog.AddEvent( new SyntaxError("Defined colour values must be an integer", line) ); continue; } sectorElements.Add( new Colour(line.dataSegments[1], colourValue, line.definition, line.docblock, line.inlineComment) ); } }
public void ParseData(AbstractSectorDataFile data) { foreach (SectorData line in data) { // Check everything starts ok if (line.rawData.Count(c => c == '"') != 2) { this.eventLogger.AddEvent( new SyntaxError("Labels may contain exactly two double quotes", line) ); continue; } if (line.rawData[0] != '"') { this.eventLogger.AddEvent( new SyntaxError("Labels must start with a name encased in quotes", line) ); continue; } // Get the name out and take the name segments off int endOfNameIndex = this.GetEndOfNameIndex(line); string name = string.Join(' ', line.dataSegments.GetRange(0, endOfNameIndex)).Trim('"'); line.dataSegments.RemoveRange(0, endOfNameIndex); if (line.dataSegments.Count != 3) { this.eventLogger.AddEvent( new SyntaxError("Invalid number of LABEL segments, expected 3", line) ); continue; } // Parse the position coordinate Coordinate parsedCoordinate = CoordinateParser.Parse(line.dataSegments[0], line.dataSegments[1]); if (parsedCoordinate.Equals(CoordinateParser.InvalidCoordinate)) { this.eventLogger.AddEvent( new SyntaxError("Invalid label coordinate format: " + data.CurrentLine, line) ); continue; } // Add to the sector elements sectorElements.Add( new Label( name, parsedCoordinate, line.dataSegments[2], line.definition, line.docblock, line.inlineComment ) ); } }
public void ParseData(AbstractSectorDataFile data) { bool doneFirstLine = false; List <SectorData> lines = new(); List <GroundNetworkTaxiway> taxiways = new(); List <GroundNetworkRunwayExit> exits = new(); foreach (SectorData line in data) { if (!doneFirstLine) { lines.Add(line); doneFirstLine = true; } else if (IsNewDeclaration(line)) { try { ProcessLines(data, lines, taxiways, exits); } catch { return; } lines.Clear(); lines.Add(line); } else { lines.Add(line); } } if (lines.Any()) { try { ProcessLines(data, lines, taxiways, exits); } catch { return; } } sectorElements.Add( new GroundNetwork( data.GetParentDirectoryName(), taxiways, exits ) ); }
public ColourValidatorTest() { sectorElements = new SectorElementCollection(); sectorElements.Add(ColourFactory.Make("colour1")); sectorElements.Add(ColourFactory.Make("colour2")); }
public void TestItPassesIfAllNamesDifferent() { sectorElements.Add(first); sectorElements.Add(third); sectorElements.Add(fifth); rule.Validate(sectorElements, args, loggerMock.Object); loggerMock.Verify(foo => foo.AddEvent(It.IsAny <ValidationRuleFailure>()), Times.Never); }
public void TestItAddsSidStars() { SidStar sidStar = SidStarFactory.Make(); collection.Add(sidStar); Assert.Equal(sidStar, collection.SidStars[0]); }