本文整理汇总了C#中RazorError.ToDiagnostics方法的典型用法代码示例。如果您正苦于以下问题:C# RazorError.ToDiagnostics方法的具体用法?C# RazorError.ToDiagnostics怎么用?C# RazorError.ToDiagnostics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RazorError
的用法示例。
在下文中一共展示了RazorError.ToDiagnostics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToDiagnostic_ConvertsRazorErrorLocation_ToSourceLineMappings
public void ToDiagnostic_ConvertsRazorErrorLocation_ToSourceLineMappings()
{
// Arrange
var sourceLocation = new SourceLocation(absoluteIndex: 30, lineIndex: 10, characterIndex: 1);
var error = new RazorError("some message", sourceLocation, length: 5);
// Act
var diagnostics = error.ToDiagnostics("/some-path");
// Assert
var span = diagnostics.Location.GetMappedLineSpan();
Assert.Equal("/some-path", span.Path);
Assert.Equal(10, span.StartLinePosition.Line);
Assert.Equal(1, span.StartLinePosition.Character);
Assert.Equal(10, span.EndLinePosition.Line);
Assert.Equal(6, span.EndLinePosition.Character);
}
示例2: ToDiagnostic_SucceedsWhenRazorErrorLocationIsZeroOrUndefined
public void ToDiagnostic_SucceedsWhenRazorErrorLocationIsZeroOrUndefined(
SourceLocation location,
int length)
{
// Arrange
var error = new RazorError("some message", location, length);
// Act
var diagnostics = error.ToDiagnostics("/some-path");
// Assert
var span = diagnostics.Location.GetMappedLineSpan();
Assert.Equal("/some-path", span.Path);
Assert.Equal(0, span.StartLinePosition.Line);
Assert.Equal(0, span.StartLinePosition.Character);
Assert.Equal(0, span.EndLinePosition.Line);
Assert.Equal(0, span.EndLinePosition.Character);
}