Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Unit test subdivs with bUnit

$
0
0

I am trying to test a blazor component. In the logic of the component i set some text in an subdiv somewhere inside the component. Now i want to verify that the text is set properly:

<div><div></div><div>        @Title</div></div>

At the moment i use the following code to instantiate the component. Now i want to verify that "title" is actually used as the title.

[Fact]public void TestSomething(){    // act    var cut = RenderComponent<MyComponent>(parameters => parameters        .Add(p => p.Title, "title")    );}

Now how would i verify that "title" is actually rendered in the right place?

I found two approaches: either i build an system to generate unique ids throughout my whole project or i just set static ids. Both are either way to much work or end in duplicate ids. Are there any better approaches to test something like this?


Viewing all articles
Browse latest Browse all 4839

Trending Articles