Skip to content

How to mark <PageTitle> as covered on a component? #879

Answered by linkdotnet
rafael-f asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @rafaelf82
you can use ComponentFactories for that.

A simple test could look like this:

[Fact]
public void ShouldSetTitle()
{
    using var ctx = new TestContext();
    ctx.ComponentFactories.AddStub<PageTitle>();

    var cut = ctx.RenderComponent<MyComponent>();

    var pageTitleStub = cut.FindComponent<Stub<PageTitle>>();
    var pageTitle = ctx.Render(pageTitleStub.Instance.Parameters.Get(p => p.ChildContent));
    pageTitle.Markup.Should().Be("My expected title");
}

Replies: 1 comment 1 reply

Comment options

linkdotnet
Oct 6, 2022
Maintainer Sponsor

You must be logged in to vote
1 reply
@rafael-f
Comment options

Answer selected by rafael-f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants