public async Task RenderAsync(CancellationToken cancellationToken = default) { var tableMessages = await Linter.AnalyseTables(Tables, cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); var viewMessages = await Linter.AnalyseViews(Views, cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); var sequenceMessages = await Linter.AnalyseSequences(Sequences, cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); var synonymMessages = await Linter.AnalyseSynonyms(Synonyms, cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); var routineMessages = await Linter.AnalyseRoutines(Routines, cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); var messages = tableMessages .Concat(viewMessages) .Concat(sequenceMessages) .Concat(synonymMessages) .Concat(routineMessages); var groupedRules = messages .GroupBy(m => m.RuleId) .Select(m => new LintResults.LintRule(m.First().Title, m.Select(r => new HtmlString(r.Message)).ToList())) .ToList(); var templateParameter = new LintResults(groupedRules); var renderedLint = await Formatter.RenderTemplateAsync(templateParameter, cancellationToken).ConfigureAwait(false); var databaseName = !IdentifierDefaults.Database.IsNullOrWhiteSpace() ? IdentifierDefaults.Database + " Database" : "Database"; var pageTitle = "Lint · " + databaseName; var lintContainer = new Container(renderedLint, pageTitle, string.Empty); var renderedPage = await Formatter.RenderTemplateAsync(lintContainer, cancellationToken).ConfigureAwait(false); if (!ExportDirectory.Exists) { ExportDirectory.Create(); } var outputPath = Path.Combine(ExportDirectory.FullName, "lint.html"); using var writer = File.CreateText(outputPath); await writer.WriteAsync(renderedPage.AsMemory(), cancellationToken).ConfigureAwait(false); await writer.FlushAsync().ConfigureAwait(false); }
public static async Task AnalyseSynonyms_GivenEmptySynonyms_ReturnsEmptyMessages() { var messages = await Linter.AnalyseSynonyms(Array.Empty <IDatabaseSynonym>()).ToListAsync().ConfigureAwait(false); Assert.That(messages, Is.Empty); }
public static void AnalyseSynonyms_GivenNullSynonyms_ThrowsArgumentNullException() { Assert.That(() => Linter.AnalyseSynonyms(null), Throws.ArgumentNullException); }