diff --git a/.github/workflows/build-samples.yml b/.github/workflows/build-samples.yml index c96e87a..9b4e1d6 100644 --- a/.github/workflows/build-samples.yml +++ b/.github/workflows/build-samples.yml @@ -14,6 +14,7 @@ on: - "aspnet-core/build-web-api-dotnet-8/**" - "aspnet-core/caching-outputcache-redis-invalidation/**" - "aspnet-core/minimal-apis-real-world/**" + - "blazor/create-interactive-ui-csharp-12/**" - ".github/workflows/build-samples.yml" pull_request: @@ -28,6 +29,7 @@ on: - "aspnet-core/build-web-api-dotnet-8/**" - "aspnet-core/caching-outputcache-redis-invalidation/**" - "aspnet-core/minimal-apis-real-world/**" + - "blazor/create-interactive-ui-csharp-12/**" - ".github/workflows/build-samples.yml" workflow_dispatch: @@ -353,3 +355,35 @@ jobs: aspnet-core/minimal-apis-real-world/MinimalApiPipeline.slnx --configuration Release --no-build + + test-blazor-todo-dashboard: + name: Test Blazor Todo Dashboard sample + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v5 + + - name: Install .NET 10 SDK + uses: actions/setup-dotnet@v5 + with: + dotnet-version: "10.0.x" + + - name: Restore + run: > + dotnet restore + blazor/create-interactive-ui-csharp-12/BlazorTodoMinimal.slnx + + - name: Build + run: > + dotnet build + blazor/create-interactive-ui-csharp-12/BlazorTodoMinimal.slnx + --configuration Release + --no-restore + + - name: Test + run: > + dotnet test + blazor/create-interactive-ui-csharp-12/BlazorTodoMinimal.slnx + --configuration Release + --no-build diff --git a/README.md b/README.md index 30ed844..3380003 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Each sample folder contains a focused implementation of one tutorial topic. The | [`aspnet-core/build-web-api-dotnet-8`](aspnet-core/build-web-api-dotnet-8/) | Minimal .NET 10 Todo API demonstrating route groups, dependency injection, CRUD status codes, validation, middleware, and integration testing | [ASP.NET Core Fundamentals: Build Web APIs on .NET 8](https://www.dotnet-guide.com/tutorials/aspnet-core/build-web-api-dotnet-8/) | | [`aspnet-core/caching-outputcache-redis-invalidation`](aspnet-core/caching-outputcache-redis-invalidation/) | Minimal .NET 10 Catalog API demonstrating Output Cache policies, query and route variation, tag eviction, write-path invalidation, and integration testing | [ASP.NET Core Caching: Output Cache, Redis & Invalidation Strategies That Actually Work](https://www.dotnet-guide.com/tutorials/aspnet-core/caching-outputcache-redis-invalidation/) | | [`aspnet-core/minimal-apis-real-world`](aspnet-core/minimal-apis-real-world/) | Focused .NET 10 Orders API demonstrating endpoint filters, FluentValidation, URL-segment versioning, typed results, and partitioned rate limiting | [ASP.NET Core / Minimal APIs in the Real World: Filters, Validation, Versioning & Rate Limiting](https://www.dotnet-guide.com/tutorials/aspnet-core/minimal-apis-real-world/) | +| [`blazor/create-interactive-ui-csharp-12`](blazor/create-interactive-ui-csharp-12/) | Interactive .NET 10 Todo Dashboard demonstrating Razor components, form binding, DataAnnotations validation, scoped state, EventCallback communication, filtering, and bUnit component tests | [Blazor Web Development: Create Interactive UIs with C# 12](https://www.dotnet-guide.com/tutorials/blazor/create-interactive-ui-csharp-12/) | ## Companion articles - [Common Microsoft.Extensions.AI mistakes](https://www.dotnet-guide.com/articles/dotnet-ai/microsoft-extensions-ai-common-mistakes/) @@ -122,6 +123,28 @@ tutorials/ | `-- TransactionalOutboxMinimal.Tests/ | |-- TransactionalOutboxMinimal.Tests.csproj | `-- OutboxFlowTests.cs +|-- blazor/ +| `-- create-interactive-ui-csharp-12/ +| |-- BlazorTodoMinimal.slnx +| |-- README.md +| |-- src/ +| | `-- BlazorTodoMinimal/ +| | |-- BlazorTodoMinimal.csproj +| | |-- Program.cs +| | |-- TodoState.cs +| | `-- Components/ +| | |-- _Imports.razor +| | |-- App.razor +| | |-- Routes.razor +| | |-- Pages/ +| | | |-- NotFound.razor +| | | `-- Todos.razor +| | `-- Shared/ +| | `-- TodoList.razor +| `-- tests/ +| `-- BlazorTodoMinimal.Tests/ +| |-- BlazorTodoMinimal.Tests.csproj +| `-- TodoDashboardTests.cs |-- aspnet-core/ | |-- api-security-in-practice/ | | |-- ApiSecurityMinimal.slnx diff --git a/blazor/create-interactive-ui-csharp-12/BlazorTodoMinimal.slnx b/blazor/create-interactive-ui-csharp-12/BlazorTodoMinimal.slnx new file mode 100644 index 0000000..6eeea81 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/BlazorTodoMinimal.slnx @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/blazor/create-interactive-ui-csharp-12/README.md b/blazor/create-interactive-ui-csharp-12/README.md new file mode 100644 index 0000000..2e7d21a --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/README.md @@ -0,0 +1,180 @@ +# Blazor Interactive Todo Dashboard — Minimal Sample + +A focused .NET 10 companion showing how Razor components, two-way binding, +`EditForm` validation, scoped state, child-component parameters, event callbacks, +and bUnit tests work together in an Interactive Server Blazor Web App. + +## Full tutorial + +[Blazor Web Development: Create Interactive UIs with C# 12](https://www.dotnet-guide.com/tutorials/blazor/create-interactive-ui-csharp-12/) + +## Framework note + +The tutorial explains Blazor on .NET 8 and C# 12. + +This companion targets .NET 10 so it can use the DOTNET GUIDE repository's +current SDK and CI toolchain. The Razor component, binding, `EditForm`, +DataAnnotations, scoped-state, `EventCallback`, and component-testing patterns +demonstrated here are the same core Blazor concepts. + +## What this sample demonstrates + +- a Blazor Web App; +- global Interactive Server rendering; +- a routable Todo Dashboard; +- `EditForm` and `DataAnnotationsValidator`; +- two-way input binding; +- field validation messages; +- a scoped in-memory state service; +- component parameters; +- `EventCallback`; +- `@key` for Todo list items; +- create, toggle, filter, and delete interactions; +- current route-aware Not Found handling; +- bUnit 2.x component tests. + +## Interaction flow + +```text +browser event + → Razor component handler + → validated form or EventCallback + → scoped TodoState update + → component re-render +``` + +## Render-mode boundary + +The sample uses Interactive Server. + +Events are processed on the server over the Blazor circuit. The browser must +maintain a connection to the application. + +This sample does not provide offline support. + +## State boundary + +`TodoState` is registered as scoped. + +In Interactive Server, scoped state is associated with the user's circuit. The +state is not a database and is not durable. + +Restarting the application or replacing the circuit resets the sample. + +## Prerequisite + +- .NET 10 SDK +- a modern browser for manual interaction checks + +Check: + +```powershell +dotnet --version +``` + +## Restore, build, and test + +```powershell +dotnet restore ` + .\BlazorTodoMinimal.slnx + +dotnet build ` + .\BlazorTodoMinimal.slnx ` + --configuration Release ` + --no-restore + +dotnet test ` + .\BlazorTodoMinimal.slnx ` + --configuration Release ` + --no-build +``` + +## Run + +```powershell +dotnet run ` + --project .\src\BlazorTodoMinimal\BlazorTodoMinimal.csproj ` + --urls http://localhost:5140 +``` + +Open: + +```text +http://localhost:5140/ +``` + +## Manual checks + +- add a valid Todo item; +- submit an invalid short title; +- toggle an item; +- filter active and completed items; +- delete an item; +- navigate to an unknown path. + +## Testing boundary + +Seven bUnit component tests render and interact with Razor components in memory. +One ASP.NET Core integration test verifies that a direct unknown-route request +returns the custom Not Found page. + +They do not launch a browser or test a live SignalR connection. Browser behavior +is covered by the manual verification steps. + +## Project structure + +```text +BlazorTodoMinimal.slnx +README.md +src/ +└── BlazorTodoMinimal/ + ├── BlazorTodoMinimal.csproj + ├── Program.cs + ├── TodoState.cs + └── Components/ + ├── _Imports.razor + ├── App.razor + ├── Routes.razor + ├── Pages/ + │ ├── NotFound.razor + │ └── Todos.razor + └── Shared/ + └── TodoList.razor +tests/ +└── BlazorTodoMinimal.Tests/ + ├── BlazorTodoMinimal.Tests.csproj + └── TodoDashboardTests.cs +``` + +## Deliberately omitted + +- Interactive WebAssembly; +- Interactive Auto; +- offline/PWA support; +- JavaScript interop; +- QuickGrid; +- virtualization; +- FluentValidation; +- authentication and authorization; +- EF Core and SQLite; +- external APIs; +- browser automation; +- Docker; +- Azure deployment; +- production persistence. + +These topics remain in the full tutorial or another focused companion. + +## Verification + +- Companion target framework: .NET 10 +- Tutorial framework: .NET 8 +- Render mode: Interactive Server +- Application NuGet packages: none +- External services required: none +- Database required: none +- API keys required: none +- Expected component/integration tests: 8 +- Last reviewed: 2026-08-02 + +This sample is educational and should be reviewed before production use. \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/BlazorTodoMinimal.csproj b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/BlazorTodoMinimal.csproj new file mode 100644 index 0000000..84d2766 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/BlazorTodoMinimal.csproj @@ -0,0 +1,9 @@ + + + + net10.0 + enable + enable + + + \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/App.razor b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/App.razor new file mode 100644 index 0000000..a35103f --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/App.razor @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Pages/NotFound.razor b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Pages/NotFound.razor new file mode 100644 index 0000000..767b143 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Pages/NotFound.razor @@ -0,0 +1,15 @@ +@page "/not-found" + +Not Found + +
+

Page not found

+ +

+ The requested page does not exist. +

+ + + Return to the Todo Dashboard + +
\ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Pages/Todos.razor b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Pages/Todos.razor new file mode 100644 index 0000000..f5c3f39 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Pages/Todos.razor @@ -0,0 +1,148 @@ +@page "/" +@inject TodoState State + +Todo Dashboard + +
+

Todo Dashboard

+ +

+ A focused Interactive Server sample using + Razor components, form validation, scoped state, + and event callbacks. +

+ +
+

+ Create a Todo item +

+ + + + +
+ + + + + +
+ +
+ + + + @foreach (TodoPriority priority + in Enum.GetValues()) + { + + } + +
+ + +
+
+ +
+

+ Current items +

+ +

+ @State.Items.Count total · + @State.Items.Count( + item => + item.IsCompleted) completed +

+ +
+ + + +
+ + +
+
+ +@code { + private TodoInput _input = + new(); + + private TodoFilter _filter = + TodoFilter.All; + + private IReadOnlyList + FilteredItems => + _filter switch + { + TodoFilter.Active => + State.Items + .Where( + item => + !item.IsCompleted) + .ToArray(), + + TodoFilter.Completed => + State.Items + .Where( + item => + item.IsCompleted) + .ToArray(), + + _ => + State.Items + }; + + private void AddTodo() + { + State.Add( + _input.Title, + _input.Priority); + + _input = + new TodoInput(); + } + + private void ToggleTodo( + int id) + { + State.Toggle( + id); + } + + private void DeleteTodo( + int id) + { + State.Delete( + id); + } +} \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Routes.razor b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Routes.razor new file mode 100644 index 0000000..724d5b2 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Routes.razor @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Shared/TodoList.razor b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Shared/TodoList.razor new file mode 100644 index 0000000..8424493 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/Shared/TodoList.razor @@ -0,0 +1,71 @@ +@if (Items.Count == 0) +{ +

+ No Todo items match the selected filter. +

+} +else +{ +
+ @foreach (TodoItem item in Items) + { +
+

@item.Title

+ +

+ Priority: + @item.Priority +

+ +

+ Status: + + @(item.IsCompleted + ? "Completed" + : "Active") + +

+ + + + +
+ } +
+} + +@code { + [Parameter] + [EditorRequired] + public IReadOnlyList Items + { + get; + set; + } = []; + + [Parameter] + public EventCallback OnToggle + { + get; + set; + } + + [Parameter] + public EventCallback OnDelete + { + get; + set; + } +} \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/_Imports.razor b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/_Imports.razor new file mode 100644 index 0000000..3caaf48 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Components/_Imports.razor @@ -0,0 +1,9 @@ +@using System.ComponentModel.DataAnnotations +@using Microsoft.AspNetCore.Components +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using BlazorTodoMinimal +@using BlazorTodoMinimal.Components +@using BlazorTodoMinimal.Components.Shared \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Program.cs b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Program.cs new file mode 100644 index 0000000..a849857 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/Program.cs @@ -0,0 +1,31 @@ +using BlazorTodoMinimal; +using BlazorTodoMinimal.Components; + +var builder = + WebApplication.CreateBuilder(args); + +builder.Services + .AddRazorComponents() + .AddInteractiveServerComponents(); + +builder.Services.AddScoped< + TodoState>(); + +var app = + builder.Build(); + +app.UseStatusCodePagesWithReExecute( + "/not-found", + createScopeForStatusCodePages: true); + +app.UseStaticFiles(); +app.UseAntiforgery(); + +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + +app.Run(); + +public partial class Program +{ +} \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/TodoState.cs b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/TodoState.cs new file mode 100644 index 0000000..2a28878 --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/src/BlazorTodoMinimal/TodoState.cs @@ -0,0 +1,137 @@ +using System.ComponentModel.DataAnnotations; + +namespace BlazorTodoMinimal; + +public sealed class TodoState +{ + private readonly List + _items = + [ + new TodoItem( + 1, + "Learn component parameters", + TodoPriority.Medium, + false), + + new TodoItem( + 2, + "Test the interactive form", + TodoPriority.High, + true) + ]; + + private int _nextId = + 2; + + public IReadOnlyList Items => + _items + .OrderBy( + item => + item.Id) + .ToArray(); + + public TodoItem Add( + string title, + TodoPriority priority) + { + int id = + ++_nextId; + + var created = + new TodoItem( + id, + title.Trim(), + priority, + false); + + _items.Add( + created); + + return created; + } + + public bool Toggle( + int id) + { + int index = + _items.FindIndex( + item => + item.Id == id); + + if (index < 0) + { + return false; + } + + TodoItem current = + _items[index]; + + _items[index] = + current with + { + IsCompleted = + !current.IsCompleted + }; + + return true; + } + + public bool Delete( + int id) + { + int index = + _items.FindIndex( + item => + item.Id == id); + + if (index < 0) + { + return false; + } + + _items.RemoveAt( + index); + + return true; + } +} + +public sealed record TodoItem( + int Id, + string Title, + TodoPriority Priority, + bool IsCompleted); + +public sealed class TodoInput +{ + [Required( + ErrorMessage = + "Title is required.")] + [StringLength( + 80, + MinimumLength = 3, + ErrorMessage = + "Title must contain between 3 and 80 characters.")] + public string Title { get; set; } = + string.Empty; + + public TodoPriority Priority + { + get; + set; + } = TodoPriority.Medium; +} + +public enum TodoPriority +{ + Low, + Medium, + High +} + +public enum TodoFilter +{ + All, + Active, + Completed +} \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/tests/BlazorTodoMinimal.Tests/BlazorTodoMinimal.Tests.csproj b/blazor/create-interactive-ui-csharp-12/tests/BlazorTodoMinimal.Tests/BlazorTodoMinimal.Tests.csproj new file mode 100644 index 0000000..ed31c5a --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/tests/BlazorTodoMinimal.Tests/BlazorTodoMinimal.Tests.csproj @@ -0,0 +1,55 @@ + + + + net10.0 + enable + enable + false + true + Exe + + + + + + + + + + + all + + runtime; + build; + native; + contentfiles; + analyzers; + buildtransitive + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/blazor/create-interactive-ui-csharp-12/tests/BlazorTodoMinimal.Tests/TodoDashboardTests.cs b/blazor/create-interactive-ui-csharp-12/tests/BlazorTodoMinimal.Tests/TodoDashboardTests.cs new file mode 100644 index 0000000..1f933dd --- /dev/null +++ b/blazor/create-interactive-ui-csharp-12/tests/BlazorTodoMinimal.Tests/TodoDashboardTests.cs @@ -0,0 +1,286 @@ +using BlazorTodoMinimal.Components.Pages; +using Bunit; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using System.Net; + +namespace BlazorTodoMinimal.Tests; + +public sealed class TodoDashboardTests +{ + [Fact] + public void + Dashboard_renders_seeded_items_and_summary() + { + using BunitContext context = + CreateContext(); + + var cut = + context.Render(); + + Assert.Equal( + 2, + cut.FindAll( + "[data-testid='todo-item']") + .Count); + + string summary = + cut.Find( + "[data-testid='summary']") + .TextContent; + + Assert.Contains( + "2 total", + summary, + StringComparison.Ordinal); + + Assert.Contains( + "1 completed", + summary, + StringComparison.Ordinal); + } + + [Fact] + public void + Valid_form_submission_adds_a_todo() + { + using BunitContext context = + CreateContext(); + + var cut = + context.Render(); + + cut.Find( + "#todo-title") + .Change( + "Write bUnit tests"); + + cut.Find( + "#todo-priority") + .Change( + TodoPriority.High + .ToString()); + + cut.Find( + "form") + .Submit(); + + cut.WaitForAssertion( + () => + { + Assert.Equal( + 3, + cut.FindAll( + "[data-testid='todo-item']") + .Count); + + Assert.Contains( + "Write bUnit tests", + cut.Markup, + StringComparison.Ordinal); + }); + } + + [Fact] + public void + Invalid_title_shows_validation_and_does_not_add() + { + using BunitContext context = + CreateContext(); + + var cut = + context.Render(); + + cut.Find( + "#todo-title") + .Change( + "x"); + + cut.Find( + "form") + .Submit(); + + cut.WaitForAssertion( + () => + { + Assert.Contains( + "Title must contain between 3 and 80 characters.", + cut.Markup, + StringComparison.Ordinal); + + Assert.Equal( + 2, + cut.FindAll( + "[data-testid='todo-item']") + .Count); + }); + } + + [Fact] + public void + Toggle_callback_updates_item_and_summary() + { + using BunitContext context = + CreateContext(); + + var cut = + context.Render(); + + cut.Find( + "[data-todo-id='1'] [data-action='toggle']") + .Click(); + + cut.WaitForAssertion( + () => + { + string summary = + cut.Find( + "[data-testid='summary']") + .TextContent; + + Assert.Contains( + "2 completed", + summary, + StringComparison.Ordinal); + + Assert.Contains( + "Mark active", + cut.Find( + "[data-todo-id='1'] [data-action='toggle']") + .TextContent, + StringComparison.Ordinal); + }); + } + + [Fact] + public void + Completed_filter_shows_only_completed_items() + { + using BunitContext context = + CreateContext(); + + var cut = + context.Render(); + + cut.Find( + "#todo-filter") + .Change( + TodoFilter.Completed + .ToString()); + + cut.WaitForAssertion( + () => + { + IReadOnlyList< + AngleSharp.Dom.IElement> items = + cut.FindAll( + "[data-testid='todo-item']"); + + Assert.Single( + items); + + Assert.Contains( + "Test the interactive form", + items[0].TextContent, + StringComparison.Ordinal); + }); + } + + [Fact] + public void + Delete_callback_removes_the_selected_item() + { + using BunitContext context = + CreateContext(); + + var cut = + context.Render(); + + cut.Find( + "[data-todo-id='2'] [data-action='delete']") + .Click(); + + cut.WaitForAssertion( + () => + { + Assert.Single( + cut.FindAll( + "[data-testid='todo-item']")); + + Assert.DoesNotContain( + "Test the interactive form", + cut.Markup, + StringComparison.Ordinal); + }); + } + + [Fact] + public void + State_add_trims_title_and_allocates_next_id() + { + var state = + new TodoState(); + + TodoItem created = + state.Add( + " Review render modes ", + TodoPriority.Low); + + Assert.Equal( + 3, + created.Id); + + Assert.Equal( + "Review render modes", + created.Title); + + Assert.False( + created.IsCompleted); + } + + [Fact] + public async Task + Unknown_path_returns_custom_not_found_page() + { + await using WebApplicationFactory< + Program> factory = + new WebApplicationFactory< + Program>(); + + using HttpClient client = + factory.CreateClient(); + + using HttpResponseMessage response = + await client.GetAsync( + "/this-page-does-not-exist", + Xunit.TestContext.Current + .CancellationToken); + + Assert.Equal( + HttpStatusCode.NotFound, + response.StatusCode); + + string body = + await response.Content + .ReadAsStringAsync( + Xunit.TestContext.Current + .CancellationToken); + + Assert.Contains( + "Page not found", + body, + StringComparison.Ordinal); + } + + private static BunitContext + CreateContext() + { + var context = + new BunitContext(); + + context.Services.AddScoped< + TodoState>(); + + return context; + } +} \ No newline at end of file