/// <nodoc /> public static Diagnostic[] ExpectCheckerDiagnostic(this TestResultBase result, TypeScript.Net.Diagnostics.IDiagnosticMessage expected, params string[] args) { var checkerDiagnostics = result.Errors.Where(e => s_checkerErrorCodes.Contains(e.ErrorCode)).ToArray(); if (!checkerDiagnostics.Any()) { var msg = string.Join(", ", s_checkerErrors.Select(e => $"'{e}'")); XAssert.Fail($"Didn't find any checher errors. Expected one of: {msg}. Actual: {result}"); } var formatted = string.Format(expected.Message, args); if (!checkerDiagnostics.Any(e => e.FullMessage.Contains(formatted))) { var foundErrors = string.Join(", ", checkerDiagnostics); XAssert.Fail($"None of the found errors contains '{formatted}'. Found errors: {foundErrors}"); } return(checkerDiagnostics); }
/// <summary> /// Evalautes everything and expects a given typechecker diagnostic id; /// </summary> public Diagnostic[] EvaluateWithCheckerDiagnostic(TypeScript.Net.Diagnostics.IDiagnosticMessage expected, params string[] args) { var result = Evaluate(); return(result.ExpectCheckerDiagnostic(expected, args)); }