public static async Task <EnvironmentCheckResults> ExecuteAllEnvironmentChecks(IServiceProvider services, CancellationToken token = default(CancellationToken)) { var results = new EnvironmentCheckResults(); var checks = services.discoverChecks().ToArray(); if (!checks.Any()) { AnsiConsole.WriteLine("No environment checks."); return(results); } await AnsiConsole.Progress().StartAsync(async c => { var task = c.AddTask("[bold]Running Environment Checks[/]", new ProgressTaskSettings { MaxValue = checks.Length }); for (int i = 0; i < checks.Length; i++) { var check = checks[i]; try { await check.Assert(services, token); AnsiConsole.MarkupLine( $"[green]{(i + 1).ToString().PadLeft(4)}.) Success: {check.Description}[/]"); results.RegisterSuccess(check.Description); } catch (Exception e) { AnsiConsole.MarkupLine( $"[red]{(i + 1).ToString().PadLeft(4)}.) Failed: {check.Description}[/]"); AnsiConsole.WriteException(e); results.RegisterFailure(check.Description, e); } finally { task.Increment(1); } } task.StopTask(); }); return(results); }
public EnvironmentCheckException(EnvironmentCheckResults results) : base(results.ToString(), results.Failures.Select(x => x.Exception)) { Results = results; }