How to mark <PageTitle> as covered on a component? #879
-
This might not be bunit related... I'm wondering how can I get this line covered on my unit tests. Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
linkdotnet
Oct 6, 2022
Replies: 1 comment 1 reply
-
Hey @rafaelf82 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");
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rafael-f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @rafaelf82
you can use
ComponentFactories
for that.A simple test could look like this: