How-To: Verify Blazor Navigation in bUnit

Blazor components and pages can have normal HTML hyperlinks and navigation driven in code. Both forms allow users to move between pages. Blazor has the NavigationManager which allows our code to perform URL navigations. And, bUnit provides a mock NavigationManager to allow test code to request a navigation without actually performing it. Under our test … Continue reading How-To: Verify Blazor Navigation in bUnit

How-To: Write bUnit Tests for Pages with Parameters

Page routing parameters allow developers to pass data to pages in their URL. bUnit allows us to pass routing parameters to pages, so that we can validate their behavior with test data. These parameters are set as part of the TestContext rendering process. This works exactly the same way as testing component parameters. First, we must have … Continue reading How-To: Write bUnit Tests for Pages with Parameters

How-To: Write bUnit Test for Component

bUnit is a testing library for Blazor components. Its goal is to make it easy to write comprehensive, stable unit tests for components. We will learn the steps to create a bUnit test class from setup to rendering to validation. This test will focus on testing a static component with a simple rendering operation. First, we must have a … Continue reading How-To: Write bUnit Test for Component

How-To: Unit Test Blazor Pages with DataBinding

Continuing with our use of the bUnit testing library for Blazor components. We will investigate how to create unit and component tests for pages/components that use both one-way and two-way data bindings. We will look at changing data on the page and performing actions (like button clicks) and then seeing how that impacts the page rendering. … Continue reading How-To: Unit Test Blazor Pages with DataBinding

App-Idea 2: Roman to Decimal

Another number conversion project (Roman-To-Decimal) takes numbers represented as roman numerals from input strings and converts them to their decimal value. Again, we will add the ability to convert back from decimals to roman numeral notation as well. This conversion project will use the same layout design as the Bin2Dec project. We will add this … Continue reading App-Idea 2: Roman to Decimal

How-To: Write First bUnit Test

bUnit is a testing library for Blazor components. Its goal is to make it easy to write comprehensive, stable unit tests for these components. We will learn the steps to create our first bUnit test from setup to rendering to validation. This first test will be very simple to allow us to focus on the mechanics of creating the … Continue reading How-To: Write First bUnit Test

Lesson 5.17: Upgrade Blazor Project and Dependencies to .NET 5

With the release of .NET 5, it is time for us to upgrade our simple-game solution to the latest version of .NET. Luckily .NET 5 is actually the next progression of .NET Core 3.1, so there aren't many major breaking changes to get this to work. We need to get onto the latest versions because … Continue reading Lesson 5.17: Upgrade Blazor Project and Dependencies to .NET 5

How-to: Add bUnit Test Project to Blazor Solution

Having automated tests for our Blazor applications is very important. We can use xUnit (or any other) test framework to write unit tests for the C# classes in our app. However, some part of our logic (even if it's just the databinding logic) lives in Blazor components and pages. For those to be tested, we … Continue reading How-to: Add bUnit Test Project to Blazor Solution