示例#1
0
        public void GetTagHelpers_DiscoversTagHelpers()
        {
            // Arrange
            var code              = $@"
public class TestTagHelper : {typeof(TagHelper).FullName}
{{
}}";
            var syntaxTree        = CSharpSyntaxTree.ParseText(code);
            var compilation       = TestCompilation.Create(Assembly, syntaxTree);
            var tagHelperResolver = new DefaultTagHelperResolver()
            {
                ForceEnableViewComponentDiscovery = true
            };

            // Act
            var result = tagHelperResolver.GetTagHelpers(compilation);

            // Assert
            Assert.Empty(result.Diagnostics);
            Assert.Equal(1, result.Descriptors.Count);
        }
示例#2
0
        public void GetTagHelpers_DiscoversViewComponentTagHelpers()
        {
            // Arrange
            var code              = @"
public class TestViewComponent
{
    public string Invoke(string foo, string bar) => null;
}";
            var syntaxTree        = CSharpSyntaxTree.ParseText(code);
            var compilation       = TestCompilation.Create(Assembly, syntaxTree);
            var tagHelperResolver = new DefaultTagHelperResolver()
            {
                ForceEnableViewComponentDiscovery = true
            };

            // Act
            var result = tagHelperResolver.GetTagHelpers(compilation);

            // Assert
            Assert.Empty(result.Diagnostics);
            Assert.Equal(1, result.Descriptors.Count);
        }