Esempio n. 1
0
        public void GetBoundTagHelperAttributes_MatchesPrefixedAttributeName()
        {
            // Arrange
            var documentDescriptors = new[]
            {
                TagHelperDescriptorBuilder.Create("TestType", "TestAssembly")
                .TagMatchingRuleDescriptor(rule => rule.RequireTagName("a"))
                .BoundAttributeDescriptor(attribute =>
                                          attribute
                                          .Name("asp-for")
                                          .TypeName(typeof(string).FullName)
                                          .PropertyName("AspFor"))
                .BoundAttributeDescriptor(attribute =>
                                          attribute
                                          .Name("asp-route")
                                          .TypeName(typeof(IDictionary <string, string>).Namespace + "IDictionary<string, string>")
                                          .PropertyName("AspRoute")
                                          .AsDictionaryAttribute("asp-route-", typeof(string).FullName))
                .Build()
            };
            var expectedAttributeDescriptors = new[]
            {
                documentDescriptors[0].BoundAttributes.Last()
            };
            var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors);
            var service         = new DefaultTagHelperFactsServiceInternal();
            var binding         = service.GetTagHelperBinding(documentContext, "a", Enumerable.Empty <KeyValuePair <string, string> >(), parentTag: null, parentIsTagHelper: false);

            // Act
            var descriptors = service.GetBoundTagHelperAttributes(documentContext, "asp-route-something", binding);

            // Assert
            Assert.Equal(expectedAttributeDescriptors, descriptors, BoundAttributeDescriptorComparer.CaseSensitive);
        }