grantcolley / headway

A .NET 7.0 Blazor framework for building configurable applications fast. Supporting both hosting models, Blazor WebAssembly and Blazor Server, a WebApi for accessing data and an Identity Provider for authentication.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Test projects to the solution

grantcolley opened this issue · comments

bUnit for testing Blazor components
AutoFixture for generating fake test data

// Install bUnit
dotnet new --install bunit.template

// Install the latest bUnit project template
dotnet new --install bunit.template::1.2.49

// Navigate to the solution folder and create a test project
dotnet new bunit -o ProjectName.Tests 

// Add the test project to the solution
dotnet sln add ProjectName.Tests/ProjectName.Tests.csproj

// Add a package reference for AutoFixture
<PackageReference Include="AutoFixture" Version="4.17.0" />

// Add using statements to the _Imports.razor file
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.Extensions.DependencyInjection
@using AutoFixture
@using Bunit.JSInterop.InvocationHandlers
@using MediatR

// Add a reference to the project containing the components to test