Skip to content

srpeirce/fluentassertions.bUnit

Repository files navigation

NuGet version (FluentAssertions.BUnit) Nuget .NET MIT License

Fluentassertions.bUnit

FluentAssertions.bUnit is an assertions library that is used in conjunction with bUnit.

It offers fluent assertions syntax to rendered components.

Why?

  • Great for TDD
  • Great for writing non-brittle tests

Getting Started

Install Nuget Package into test project:

dotnet install FluentAssertions.BUnit

Use bUnit to render component.

Then write assertions...

    [Fact]
    public void RenderWithChildContent()
    {
        Render(@<Button><h1>Test</h1></Button>)
            .Should().HaveTag("button")
            .And.HaveChildMarkup(@<h1>Test</h1>);
    }

    [Fact]
    public void SetDefaultCssClasses()
    {
        Render(@<Button><h1>Test</h1></Button>)
            .Should().HaveClass("btn")
            .And.HaveClass("btn-primary")
            .And.NotHaveClass("btn-outline-success");
    }

Documentation

Use intellisense and look at the code for now :-)

Find Element

Find Element

Assertions

Assertions

Contributions

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).

Sponsors

Thanks Powered4 TV for supporting us.

About

Fluent Assertions for bUnit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •