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

Lesson 6.3: Create Blob Storage Repository

In Chapter 5, we created a repository interface (IReadableRepository) and repository implementation (InMemoryReadRepository) that loaded data from embedded resource files. We designed our system with these abstractions because we want to try out several Azure storage technologies, and the repository interface gives our service code a measure of isolation from the data implementation technologies. As … Continue reading Lesson 6.3: Create Blob Storage Repository

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

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

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

Lesson 1.9: Unit Testing Commands

The detailed description for just one test and how to run it got longer than expected, so we are putting the remaining command tests in this separate lesson. We won't go over each test in excruciating detail in this lesson. Instead, we will only focus on the differences or uniqueness of particular tests. For detailed … Continue reading Lesson 1.9: Unit Testing Commands

Lesson 1.8: Our First Command Unit Test

Having created our unit test project in lesson 1.7, we are ready to start writing some tests. This lesson will focus on the mechanics of setting up our first test in xUnit, how to mock our IUniversityRepository dependency, and the strategy of which tests to write to cover all of the scenarios for our commands. … Continue reading Lesson 1.8: Our First Command Unit Test

Lesson 1.7: Setting Up Unit Test Project

Testing is an important part of any project or command-line app. Spectre.Console.Cli is designed very well to support unit testing of commands. Unit tests are isolated tests meant to test just the code and logic within a component, or a command in the case of CLI apps. Using interfaces for dependent components and dependency injection … Continue reading Lesson 1.7: Setting Up Unit Test Project

Lesson 5.5: Create Web Service to Retrieve ItemTemplates

With a working Azure Functions project in place, we are ready to start moving code into our web service. We have various sources of game data: items, monsters, locations, quests, recipes, and traders. Each of these data sources would make a great web service. So let's start by creating a simple web service that loads … Continue reading Lesson 5.5: Create Web Service to Retrieve ItemTemplates

Lesson 4.2: Refactoring to Use Attack Command

With a working game engine, it's time for some changes to make it more flexible and able to support an ever-growing list of features and functions. One large refactoring that we will make is to replace the weapon and monster attack behavior with an Attack command instead. We will learn and use the Command design … Continue reading Lesson 4.2: Refactoring to Use Attack Command