public void TestItSendsErrorEventOnMissingConfigFile() { CompilerArgumentsValidator.Validate(this.eventLogger.Object, this.arguments); string expectedMessage = "No config files specified"; eventLogger.Verify( foo => foo.AddEvent(It.Is <CompilerArgumentError>(arg => arg.GetMessage().Contains(expectedMessage))) ); }
public void TestItSetsNoErrorsOnValidConfig() { arguments.ConfigFiles.Add(mockConfigFile); CompilerArgumentsValidator.Validate(this.eventLogger.Object, this.arguments); eventLogger.VerifyNoOtherCalls(); }
public int Compile() { events.AddEvent(new ComplilationStartedEvent()); CompilerArgumentsValidator.Validate(events, arguments); if (events.HasFatalError()) { events.AddEvent(new CompilationFinishedEvent(false)); return(1); } // Parse all the config files OutputGroupRepository outputGroups = new OutputGroupRepository(); ConfigInclusionRules config; try { events.AddEvent(new CompilationMessage("Loading config files")); config = ConfigFileLoaderFactory.Make().LoadConfigFiles(arguments.ConfigFiles, arguments); } catch (ConfigFileInvalidException e) { events.AddEvent(new CompilationMessage(e.Message)); events.AddEvent(new CompilationFinishedEvent(false)); return(1); } // Parse all the input files and create elements SectorElementCollection sectorElements = new SectorElementCollection(); DataParserFactory parserFactory = new DataParserFactory(sectorElements, events); InputFileList fileList; try { events.AddEvent(new CompilationMessage("Building input file list")); fileList = InputFileListFactory.CreateFromInclusionRules( new SectorDataFileFactory(new InputFileStreamFactory()), config, outputGroups ); } catch (System.Exception exception) { events.AddEvent(new CompilationMessage(exception.Message)); events.AddEvent(new CompilationFinishedEvent(false)); return(1); } events.AddEvent(new CompilationMessage("Injecting pre-parse static data")); RunwayCentrelineInjector.InjectRunwayCentrelineData(sectorElements); events.AddEvent(new CompilationMessage("Parsing input files")); foreach (AbstractSectorDataFile dataFile in fileList) { parserFactory.GetParserForFile(dataFile).ParseData(dataFile); } if (events.HasFatalError()) { events.AddEvent(new CompilationFinishedEvent(false)); return(1); } // There's some static data we need to inject to the collection for adjacent airports... events.AddEvent(new CompilationMessage("Injecting post-parse static data")); AdjacentAirportsInjector.InjectAdjacentAirportsData(sectorElements); // Now all the data is loaded, validate that there are no broken references etc. if (arguments.ValidateOutput) { events.AddEvent(new CompilationMessage("Validating data")); OutputValidator.Validate(sectorElements, arguments, events); if (events.HasFatalError()) { events.AddEvent(new CompilationFinishedEvent(false)); return(1); } } else { events.AddEvent(new CompilationMessage("Skipping output validation")); } // Generate the output OutputGenerator generator = new OutputGenerator( sectorElements, outputGroups, new CompilableElementCollectorFactory(sectorElements, outputGroups) ); foreach (AbstractOutputFile output in arguments.OutputFiles) { events.AddEvent(new CompilationMessage($"Generating {output.GetFileDescriptor()} output")); generator.GenerateOutput(output); } events.AddEvent(new CompilationFinishedEvent(true)); return(0); }