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 DefaultTagHelperFactsService(); 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.Default); }
public void GetBoundTagHelperAttributes_MatchesAttributeName() { // Arrange var documentDescriptors = new[] { TagHelperDescriptorBuilder.Create("TestType", "TestAssembly") .TagMatchingRuleDescriptor(rule => rule.RequireTagName("input")) .BoundAttributeDescriptor(attribute => attribute .Name("asp-for") .TypeName(typeof(string).FullName) .PropertyName("AspFor")) .BoundAttributeDescriptor(attribute => attribute .Name("asp-extra") .TypeName(typeof(string).FullName) .PropertyName("AspExtra")) .Build() }; var expectedAttributeDescriptors = new[] { documentDescriptors[0].BoundAttributes.First() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); var service = new DefaultTagHelperFactsService(); var binding = service.GetTagHelperBinding(documentContext, "input", Enumerable.Empty <KeyValuePair <string, string> >(), parentTag: null, parentIsTagHelper: false); // Act var descriptors = service.GetBoundTagHelperAttributes(documentContext, "asp-for", binding); // Assert Assert.Equal(expectedAttributeDescriptors, descriptors, BoundAttributeDescriptorComparer.CaseSensitive); }