public ISourceInformation?GetSourceInformation(Type testComponent, RazorTestBase test, int testNumber) { DiagnosticMessageSink.OnMessage(new DiagnosticMessage($"{nameof(GetSourceInformation)}({testComponent.Name}): Attempting to find source file")); try { if (TryFindSourceFile(testComponent, out var razorFile)) { var lineNumber = FindLineNumber(razorFile, test, testNumber); DiagnosticMessageSink.OnMessage(new DiagnosticMessage($"{nameof(GetSourceInformation)}({testComponent.Name}): Source info found: File = {razorFile}, LineNumber = {lineNumber}")); return(new SourceInformation { FileName = razorFile, LineNumber = lineNumber ?? 1 }); } } catch (Exception ex) { DiagnosticMessageSink.OnMessage(new DiagnosticMessage($"{nameof(GetSourceInformation)}({testComponent.Name}): Failed to find source information. Exception message: " + $"{ex.Message}{Environment.NewLine}{ex.StackTrace}")); } return(null); }
private static string GetDisplayName(RazorTestBase test, int testNumber) => test.DisplayName ?? $"{test.GetType().Name} #{testNumber}";
private void RegisterXunitHelpersInTest(RazorTestBase test) { test.Services.AddSingleton <ITestOutputHelper>(_ => _testOutputHelperFactory()); }