Beispiel #1
0
        public async Task RunAsync_AllowsDataRetrievalFromTagHelperContext()
        {
            // Arrange
            var runner           = new TagHelperRunner();
            var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
            var tagHelper        = new TagHelperContextTouchingTagHelper();

            // Act
            executionContext.Add(tagHelper);
            executionContext.AddTagHelperAttribute("foo", true, HtmlAttributeValueStyle.DoubleQuotes);
            await runner.RunAsync(executionContext);

            // Assert
            Assert.Equal("True", executionContext.Output.Attributes["foo"].Value);
        }
Beispiel #2
0
        public async Task RunAsync_SetsTagHelperOutputTagMode(TagMode tagMode)
        {
            // Arrange
            var runner           = new TagHelperRunner();
            var executionContext = new TagHelperExecutionContext("p", tagMode);
            var tagHelper        = new TagHelperContextTouchingTagHelper();

            executionContext.Add(tagHelper);
            executionContext.AddTagHelperAttribute("foo", true, HtmlAttributeValueStyle.DoubleQuotes);

            // Act
            await runner.RunAsync(executionContext);

            // Assert
            Assert.Equal(tagMode, executionContext.Output.TagMode);
        }
        public void TagHelperExecutionContext_MaintainsAllAttributes()
        {
            // Arrange
            var executionContext   = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
            var expectedAttributes = new TagHelperAttributeList
            {
                { "class", "btn" },
                { "something", true },
                { "foo", "bar" }
            };

            // Act
            executionContext.AddHtmlAttribute("class", "btn");
            executionContext.AddTagHelperAttribute("something", true);
            executionContext.AddHtmlAttribute("foo", "bar");
            var context = executionContext.Context;

            // Assert
            Assert.Equal(
                expectedAttributes,
                context.AllAttributes,
                CaseSensitiveTagHelperAttributeComparer.Default);
        }
        public void TagHelperExecutionContext_MaintainsAllAttributes()
        {
            // Arrange
            var executionContext   = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
            var expectedAttributes = new TagHelperAttributeList
            {
                { "class", "btn" },
            };

            expectedAttributes.Add(new TagHelperAttribute("something", true, HtmlAttributeValueStyle.SingleQuotes));
            expectedAttributes.Add(new TagHelperAttribute("type", "text", HtmlAttributeValueStyle.NoQuotes));

            // Act
            executionContext.AddHtmlAttribute("class", "btn", HtmlAttributeValueStyle.DoubleQuotes);
            executionContext.AddTagHelperAttribute("something", true, HtmlAttributeValueStyle.SingleQuotes);
            executionContext.AddHtmlAttribute("type", "text", HtmlAttributeValueStyle.NoQuotes);
            var context = executionContext.Context;

            // Assert
            Assert.Equal(
                expectedAttributes,
                context.AllAttributes,
                CaseSensitiveTagHelperAttributeComparer.Default);
        }
        public void TagHelperExecutionContext_MaintainsAllAttributes()
        {
            // Arrange
            var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
            var expectedAttributes = new TagHelperAttributeList
            {
                { "class", "btn" },
            };
            expectedAttributes.Add(new TagHelperAttribute("something", true, HtmlAttributeValueStyle.SingleQuotes));
            expectedAttributes.Add(new TagHelperAttribute("type", "text", HtmlAttributeValueStyle.NoQuotes));

            // Act
            executionContext.AddHtmlAttribute("class", "btn", HtmlAttributeValueStyle.DoubleQuotes);
            executionContext.AddTagHelperAttribute("something", true, HtmlAttributeValueStyle.SingleQuotes);
            executionContext.AddHtmlAttribute("type", "text", HtmlAttributeValueStyle.NoQuotes);
            var context = executionContext.Context;

            // Assert
            Assert.Equal(
                expectedAttributes,
                context.AllAttributes,
                CaseSensitiveTagHelperAttributeComparer.Default);
        }
Beispiel #6
0
        public async Task RunAsync_AllowsDataRetrievalFromTagHelperContext()
        {
            // Arrange
            var runner = new TagHelperRunner();
            var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
            var tagHelper = new TagHelperContextTouchingTagHelper();

            // Act
            executionContext.Add(tagHelper);
            executionContext.AddTagHelperAttribute("foo", true, HtmlAttributeValueStyle.DoubleQuotes);
            await runner.RunAsync(executionContext);

            // Assert
            Assert.Equal("True", executionContext.Output.Attributes["foo"].Value);
        }
Beispiel #7
0
        public async Task RunAsync_SetsTagHelperOutputTagMode(TagMode tagMode)
        {
            // Arrange
            var runner = new TagHelperRunner();
            var executionContext = new TagHelperExecutionContext("p", tagMode);
            var tagHelper = new TagHelperContextTouchingTagHelper();

            executionContext.Add(tagHelper);
            executionContext.AddTagHelperAttribute("foo", true, HtmlAttributeValueStyle.DoubleQuotes);

            // Act
            await runner.RunAsync(executionContext);

            // Assert
            Assert.Equal(tagMode, executionContext.Output.TagMode);
        }