public override void Attribute(Action <RequiredAttributeDescriptorBuilder> configure)
        {
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            EnsureRequiredAttributeBuilders();

            var builder = new DefaultRequiredAttributeDescriptorBuilder();

            configure(builder);
            _requiredAttributeBuilders.Add(builder);
        }
        public void Build_DisplayNameIsNameWithDots_NameComparisonPrefixMatch()
        {
            // Arrange
            var builder = new DefaultRequiredAttributeDescriptorBuilder();

            builder
            .Name("asp-route-")
            .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch);

            // Act
            var descriptor = builder.Build();

            // Assert
            Assert.Equal("asp-route-...", descriptor.DisplayName);
        }
        public void Build_DisplayNameIsName_NameComparisonFullMatch()
        {
            // Arrange
            var builder = new DefaultRequiredAttributeDescriptorBuilder();

            builder
            .Name("asp-action")
            .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch);

            // Act
            var descriptor = builder.Build();

            // Assert
            Assert.Equal("asp-action", descriptor.DisplayName);
        }
Пример #4
0
        public void Build_DisplayNameIsNameWithDots_NameComparisonPrefixMatch()
        {
            // Arrange
            var tagHelperBuilder       = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test");
            var tagMatchingRuleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder);
            var builder = new DefaultRequiredAttributeDescriptorBuilder(tagMatchingRuleBuilder);

            builder
            .Name("asp-route-")
            .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch);

            // Act
            var descriptor = builder.Build();

            // Assert
            Assert.Equal("asp-route-...", descriptor.DisplayName);
        }
        public void Matches_ReturnsExpectedResult(
            Action <RequiredAttributeDescriptorBuilder> configure,
            string attributeName,
            string attributeValue,
            bool expectedResult)
        {
            // Arrange

            var builder = new DefaultRequiredAttributeDescriptorBuilder();

            configure(builder);

            var requiredAttibute = builder.Build();

            // Act
            var result = TagHelperMatchingConventions.SatisfiesRequiredAttribute(attributeName, attributeValue, requiredAttibute);

            // Assert
            Assert.Equal(expectedResult, result);
        }