FluentAssertions.bUnit is an assertions library that is used in conjunction with bUnit.
It offers fluent assertions syntax to rendered components.
- Great for TDD
- Great for writing non-brittle tests
Install Nuget Package into test project:
dotnet install FluentAssertions.BUnit
Use bUnit to render component.
Then write assertions...
[Fact]publicvoidRenderWithChildContent(){Render(@<Button><h1>Test</h1></Button>).Should().HaveTag("button").And.HaveChildMarkup(@<h1>Test</h1>);}[Fact]publicvoidSetDefaultCssClasses(){Render(@<Button><h1>Test</h1></Button>).Should().HaveClass("btn").And.HaveClass("btn-primary").And.NotHaveClass("btn-outline-success");}Use intellisense and look at the code for now :-)
Currently in a very early version/stage of this project.
Please raise issues and feel free to submit PRs (happy to discuss in an issue first to avoid wasted effort).
Thanks Powered4 TV for supporting us.