public async Task ProcessAsync_AlreadyHaveTitleThrowsInvalidOperationException()
        {
            // Arrange
            var errorSummaryContext = new ErrorSummaryContext();

            errorSummaryContext.TrySetTitle(attributes: null, new HtmlString("Existing title"));

            var context = new TagHelperContext(
                tagName: "govuk-error-summary-title",
                allAttributes: new TagHelperAttributeList(),
                items: new Dictionary <object, object>()
            {
                { typeof(ErrorSummaryContext), errorSummaryContext }
            },
                uniqueId: "test");

            var output = new TagHelperOutput(
                "govuk-error-summary-title",
                attributes: new TagHelperAttributeList(),
                getChildContentAsync: (useCachedResult, encoder) =>
            {
                var tagHelperContent = new DefaultTagHelperContent();
                tagHelperContent.SetContent("Some title");
                return(Task.FromResult <TagHelperContent>(tagHelperContent));
            });

            var tagHelper = new ErrorSummaryTitleTagHelper();

            // Act
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => tagHelper.ProcessAsync(context, output));

            Assert.Equal("Cannot render <govuk-error-summary-title> here.", ex.Message);
        }
        public async Task ProcessAsync_AddsTitleToContext()
        {
            // Arrange
            var errorSummaryContext = new ErrorSummaryContext();

            var context = new TagHelperContext(
                tagName: "govuk-error-summary-title",
                allAttributes: new TagHelperAttributeList(),
                items: new Dictionary <object, object>()
            {
                { typeof(ErrorSummaryContext), errorSummaryContext }
            },
                uniqueId: "test");

            var output = new TagHelperOutput(
                "govuk-error-summary-title",
                attributes: new TagHelperAttributeList(),
                getChildContentAsync: (useCachedResult, encoder) =>
            {
                var tagHelperContent = new DefaultTagHelperContent();
                tagHelperContent.SetContent("Some title");
                return(Task.FromResult <TagHelperContent>(tagHelperContent));
            });

            var tagHelper = new ErrorSummaryTitleTagHelper();

            // Act
            await tagHelper.ProcessAsync(context, output);

            // Assert
            Assert.Equal("Some title", errorSummaryContext.Title?.content.AsString());
        }