コード例 #1
0
        public async Task GetNavigatePositionAsync_TagHelperProperty_IgnoreInnerProperty()
        {
            // Arrange
            var content = @"

<div>@Title</div>

@code
{
    private class NotTheDroidsYoureLookingFor
    {
        public string Title { get; set; }
    }

    public string [|Title|] { get; set; }
}
";

            TestFileMarkupParser.GetSpan(content, out content, out var selection);

            SetupDocument(out var codeDocument, out _, content);
            var expectedRange = selection.AsRange(codeDocument.GetSourceText());

            var mappingService = new DefaultRazorDocumentMappingService(LoggerFactory);

            // Act II
            var range = await RazorDefinitionEndpoint.TryGetPropertyRangeAsync(codeDocument, "Title", mappingService, Logger, CancellationToken.None).ConfigureAwait(false);

            Assert.NotNull(range);
            Assert.Equal(expectedRange, range);
        }
コード例 #2
0
        public async Task GetNavigatePositionAsync_TagHelperProperty_CorrectRange2()
        {
            // Arrange
            var content = @"

<div>@Title</div>

@code
{
    [Microsoft.AspNetCore.Components.Parameter]
    public string [|Title|] { get; set; }
}
";

            TestFileMarkupParser.GetSpan(content, out content, out var selection);

            SetupDocument(out var codeDocument, out _, content);
            var expectedRange = selection.AsRange(codeDocument.GetSourceText());

            var mappingService = new DefaultRazorDocumentMappingService(LoggerFactory);

            // Act II
            var range = await RazorDefinitionEndpoint.TryGetPropertyRangeAsync(codeDocument, "Title", mappingService, Logger, CancellationToken.None).ConfigureAwait(false);

            Assert.NotNull(range);
            Assert.Equal(expectedRange, range);
        }