I was working on GitHub on a new project and wanted to build and locally publish some NuGet packages in that repository. While doing a bunch of searching on the web, I found this article by Andrew Craven extremely useful: A NuGet package workflow using GitHub Actions!
Tag: How-To
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: Use Class File for Blazor Logic Code
As our logic continues to grow and our testing requirements increase, we will find that it is more efficient to separate our application logic from the rendering logic on pages. This split helps us separate these concerns and build cleaner pages. Also, having the logic within a separate C# class allows us to unit test … Continue reading How-To: Use Class File for Blazor Logic Code
How-To: Use Blazor Code-Behind File
In Blazor, sometimes our page code becomes large and cumbersome. Rather than keep all of the HTML markup and C# code in the same .razor file, we can split our markup and code into separate files. Blazor supports creating code-behind files for the .razor file (similar to other .NET technologies like WinForms, ASP.NET, WPF, etc). … Continue reading How-To: Use Blazor Code-Behind File
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 Tests for Components with Parameters
Component parameters allow developers to build interactive and reusable Blazor components. bUnit provides us a couple of mechanisms for passing parameters to components, so that we can validate their behavior with test data. These parameters are set as part of the TestContext rendering process. First, we must have a Blazor project and corresponding test project. … Continue reading How-To: Write bUnit Tests for Components 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: 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
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