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

App-Idea 6: JSON to CSV Converter (Part 1)

The next app that we will look at is the JSON to CSV Converter, which allows users to enter text in a simplified JSON format and converts it into a comma-separated value (CSV) format. To map easily to the flat CSV structure, our JSON input won't deeply support nested objects. This app-idea has more complex … Continue reading App-Idea 6: JSON to CSV Converter (Part 1)

How-To: Define Routing Parameters on Blazor Page

As with Blazor components, we can also define parameters on a page. These parameters have slightly different meaning and are usually referred to as routing parameters. The Blazor routing engine will map segments of a URL to matching parameters on that page object. If no matching routes exist, then the "Not Found" message is displayed … Continue reading How-To: Define Routing Parameters on Blazor Page

How-To: Define EventCallback on Blazor Component

In some cases, a Blazor component needs to inform its parent of a state change. Blazor uses an EventCallback to define how events are passed from a component to its parent component or page. That parent's method gets called whenever the child component's event is fired. Defining an EventCallback is similar to how we place … Continue reading How-To: Define EventCallback on Blazor Component

Lesson 6.4: Refactor Services to Consume Multiple Repositories

In the previous lesson, we created a new BlobStorageReadRepository and exposed various typed instances of it through our RepositoryFactory. Today, we are going to update our FunctionServiceHelper to switch between target repositories based on a query string parameter. This will allow us to easily test our game services using different back end Azure storage solutions. … Continue reading Lesson 6.4: Refactor Services to Consume Multiple Repositories

How-To: Define Parameters on a Blazor Component

Components can be made more generic by passing in parameter data which the component then uses in its layout and rendering. Rather than hard-coding all of the content of a component, we can expose parameters that allow the component users some flexibility. Component parameters are defined using public simple or complex properties on the component … Continue reading How-To: Define Parameters on a Blazor Component

How-To: Create New Blazor Component

Blazor apps are based on components. A component in Blazor is the atomic unit of composition for any UI element, such as a page, control, dialog, or data entry form. Components are .NET C# classes built into assemblies. They can: Define UI rendering logic.Handle user events.Be nested and reused.Be shared and distributed as Razor class libraries or NuGet packages. The … Continue reading How-To: Create New Blazor 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: Create Blazor App Splash Screen

When applications require time to load up, they usually provide a splash screen to give the user something to watch, provide feedback that the application is loading, and start building the user interface branding for the app. Blazor also has the ability to show an HTML splash screen, while the Blazor WebAssembly and possibly the … Continue reading How-To: Create Blazor App Splash Screen