Example #1
0
        static int Validate(MarkdownContextValidator validator, int errorThreshold, bool warningIsError)
        {
            CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(1));
            var report = validator.ValidateFully(tokenSource.Token);

            if (tokenSource.IsCancellationRequested)
            {
                WriteLine("Failed to validate within a minute. This indicates a problem with a parser.", ConsoleColor.Red);
                return(1);
            }

            WriteLine("Validation complete.", ConsoleColor.Green);

            if (report.WarningCount == 0)
            {
                WriteLine("No problems found.", ConsoleColor.Green);
                return(0);
            }

            Console.WriteLine();
            PrintWarnings(report);

            int errorCount = warningIsError ? report.WarningCount : report.ErrorCount;

            return(errorCount <= errorThreshold ? 0 : 1);
        }
Example #2
0
        public void ValidationReport_Equals_Empty()
        {
            var validator = new MarkdownContextValidator();

            Assert.Equal(validator.Validate(), validator.ValidateFully());
        }