public void GetTagHelpersGivenParent_RestrictsTagHelpersBasedOnParent()
        {
            // Arrange
            var expectedDescriptors = new[]
            {
                TagHelperDescriptorBuilder.Create("TestType", "TestAssembly")
                .TagMatchingRuleDescriptor(
                    rule => rule
                    .RequireTagName("p")
                    .RequireParentTag("div"))
                .Build()
            };
            var documentDescriptors = new[]
            {
                expectedDescriptors[0],
                TagHelperDescriptorBuilder.Create("TestType2", "TestAssembly")
                .TagMatchingRuleDescriptor(
                    rule => rule
                    .RequireTagName("strong")
                    .RequireParentTag("p"))
                .Build()
            };
            var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors);
            var service         = new DefaultTagHelperFactsService();

            // Act
            var descriptors = service.GetTagHelpersGivenParent(documentContext, "div");

            // Assert
            Assert.Equal(expectedDescriptors, descriptors, TagHelperDescriptorComparer.CaseSensitive);
        }
        public void GetTagHelpersGivenParent_AllowsRootParentTagForParentRestrictedTagHelperDescriptors()
        {
            // Arrange
            var documentDescriptors = new[]
            {
                TagHelperDescriptorBuilder.Create("DivTagHelper", "TestAssembly")
                .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div"))
                .Build(),
                TagHelperDescriptorBuilder.Create("PTagHelper", "TestAssembly")
                .TagMatchingRuleDescriptor(rule => rule
                                           .RequireTagName("p")
                                           .RequireParentTag("body"))
                .Build()
            };
            var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors);
            var service         = new DefaultTagHelperFactsService();

            // Act
            var descriptors = service.GetTagHelpersGivenParent(documentContext, parentTag: null /* root */);

            // Assert
            var descriptor = Assert.Single(descriptors);

            Assert.Equal(documentDescriptors[0], descriptor, TagHelperDescriptorComparer.CaseSensitive);
        }