Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5b862fd
Add GetRouteUrlHelper
hishamco Sep 15, 2020
c148d1a
Fix package name
hishamco Sep 15, 2020
b3b2391
Bump Newtonsoft.Json from 12.0.3 to 13.0.2 in /samples/BeforeWebForms
dependabot[bot] Dec 8, 2022
e7f39aa
Merge pull request #268 from FritzAndFriends/dependabot/nuget/samples…
csharpfritz Aug 7, 2023
00aa2ab
Bump jQuery from 3.4.1 to 3.5.0 in /samples/BeforeWebForms
dependabot[bot] Aug 7, 2023
2d5ed0a
Bump System.Drawing.Common in /src/BlazorWebFormsComponents
dependabot[bot] Aug 7, 2023
63bf8d3
Merge pull request #270 from FritzAndFriends/dependabot/nuget/samples…
csharpfritz Jan 14, 2026
558b00a
Merge pull request #271 from FritzAndFriends/dependabot/nuget/src/Bla…
csharpfritz Jan 14, 2026
9ca14c3
Merge branch 'dev' into get-route-url
csharpfritz Jan 14, 2026
1679380
Merge pull request #252 from hishamco/get-route-url
csharpfritz Jan 14, 2026
815c9fc
Update to .NET 10 and configure for Copilot (#273)
csharpfritz Jan 28, 2026
ec11a6a
Menu component (#274)
csharpfritz Jan 28, 2026
bb03830
Fixed tests (#275)
csharpfritz Jan 28, 2026
859554e
Enhance CI workflow: add 'dev' branch support and improve test result…
csharpfritz Jan 28, 2026
2ebabc2
Add installation step for libssl1.1 in CI workflow
csharpfritz Jan 28, 2026
3d058a1
Add installation step for libssl1.1 in CI workflow (#277)
csharpfritz Jan 28, 2026
7e4eb4c
Fix indentation for libssl1.1 installation step in CI workflow
csharpfritz Jan 28, 2026
7594bbd
Merge branch 'dev' into dev
csharpfritz Jan 28, 2026
a058830
Fix indentation for libssl1.1 installation step in CI workflow
csharpfritz Jan 28, 2026
bdbc95f
Update Nerdbank.GitVersioning package version to 3.9.50
csharpfritz Jan 28, 2026
34c99ad
Remove installation step for libssl1.1 from CI workflow
csharpfritz Jan 28, 2026
96e3ba9
Fixing spaces in YML (#278)
csharpfritz Jan 28, 2026
50717c9
Implement CheckBox component (#280)
Copilot Jan 28, 2026
a268094
Implement RadioButton component (#284)
Copilot Jan 28, 2026
247cb05
Implement DropDownList component with shared ListItem infrastructure …
Copilot Jan 28, 2026
39d60c0
Implement TextBox component with HTML5 input type support (#286)
Copilot Jan 28, 2026
fd54488
Merge branch 'dev' of github.com:FritzAndFriends/BlazorWebFormsCompon…
csharpfritz Jan 28, 2026
0354c24
Add guidelines and templates for creating sample pages in documentation
csharpfritz Jan 28, 2026
72a6f0a
Updated with demo code
csharpfritz Jan 28, 2026
ef3854c
Merge pull request #287 from csharpfritz/chore-samples
csharpfritz Jan 28, 2026
d59f5ac
Add comprehensive Playwright integration tests with interactive compo…
Copilot Jan 29, 2026
e524d76
Set version to '0.14-preview'
csharpfritz Jan 29, 2026
3f70773
Update checkout action to version 4
csharpfritz Jan 29, 2026
87a7259
Update Dockerfile to use specific package versions
csharpfritz Jan 29, 2026
4fcde36
Update Dockerfile to use specific package versions
csharpfritz Jan 29, 2026
8768cc4
Added missing docsc
csharpfritz Jan 29, 2026
2baaee4
Missing docs
csharpfritz Jan 29, 2026
82f5e02
feat: Add CheckBoxList, ListBox, RadioButtonList, Panel, and PlaceHol…
csharpfritz Jan 29, 2026
c44fc6b
Merge branch 'dev' of github.com:FritzAndFriends/BlazorWebFormsCompon…
csharpfritz Jan 29, 2026
cc78eba
Merge branch 'dev' into v0.13
csharpfritz Jan 29, 2026
e5c8f0c
back to v0.13
csharpfritz Jan 29, 2026
3967a15
Merge branch 'main' into v0.13
csharpfritz Jan 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
486 changes: 486 additions & 0 deletions .github/copilot-instructions.md

Large diffs are not rendered by default.

237 changes: 237 additions & 0 deletions .github/skills/bunit-test-migration/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
---
name: bunit-test-migration
description: Migrate bUnit test files from deprecated beta API (1.0.0-beta-10) to bUnit 2.x stable API. Use this when working on .razor test files in BlazorWebFormsComponents.Test that contain old patterns like TestComponentBase, Fixture, or SnapshotTest.
---

# bUnit Test Migration Skill (Beta → 2.x)

This skill provides guidance for migrating test files from the deprecated bUnit 1.0.0-beta-10 API to bUnit 2.5.3 stable API. Use this when you encounter test files using the old `TestComponentBase`, `<Fixture>`, or `<SnapshotTest>` patterns.

## When to Apply

Apply this skill when a `.razor` test file contains any of these patterns:
- `@inherits TestComponentBase`
- `<Fixture Test="...">`
- `<ComponentUnderTest>`
- `<SnapshotTest>`
- `void MethodName(Fixture fixture)`

## Transformation Rules

### 1. Change Inheritance

```diff
- @inherits TestComponentBase
+ @inherits BunitContext
```

### 2. Remove Wrapper Elements

Remove these XML elements entirely (keep only the component inside):

```diff
- <Fixture Test="TestName">
- <ComponentUnderTest>
<MyComponent Parameter="value" />
- </ComponentUnderTest>
- </Fixture>
```

### 3. Convert Test Methods

```diff
- void TestMethodName(Fixture fixture)
+ [Fact]
+ public void ComponentName_Scenario_ExpectedResult()
```

### 4. Replace Component Access

```diff
- var cut = fixture.GetComponentUnderTest();
+ var cut = Render(@<MyComponent Parameter="value" />);
```

### 5. Convert Snapshot Tests

```diff
- <SnapshotTest Description="renders correctly">
- <TestInput>
- <MyComponent />
- </TestInput>
- <ExpectedOutput>
- <div>expected html</div>
- </ExpectedOutput>
- </SnapshotTest>
+ [Fact]
+ public void MyComponent_Default_RendersCorrectly()
+ {
+ var cut = Render(@<MyComponent />);
+ cut.MarkupMatches(@<div>expected html</div>);
+ }
```

## Complete Example

### Before

```razor
@inherits TestComponentBase

<Fixture Test="ShouldClickButton">
<ComponentUnderTest>
<Button OnClick="OnClick">Click me</Button>
</ComponentUnderTest>
</Fixture>

@code {
int ClickCount = 0;

void ShouldClickButton(Fixture fixture)
{
var cut = fixture.GetComponentUnderTest();

cut.Find("button").Click();

ClickCount.ShouldBe(1);
}

void OnClick() => ClickCount++;
}
```

### After

```razor
@inherits BunitContext

@code {
int ClickCount = 0;

[Fact]
public void Button_Click_IncrementsCounter()
{
var cut = Render(@<Button OnClick="OnClick">Click me</Button>);

cut.Find("button").Click();

ClickCount.ShouldBe(1);
}

void OnClick() => ClickCount++;
}
```

## Test Naming Convention

Pattern: `ComponentName_Scenario_ExpectedResult`

| Component | Scenario | Result | Test Name |
|-----------|----------|--------|-----------|
| Button | Click | InvokesHandler | `Button_Click_InvokesHandler` |
| DataList | EmptySource | ShowsEmptyTemplate | `DataList_EmptySource_ShowsEmptyTemplate` |
| GridView | WithData | RendersRows | `GridView_WithData_RendersRows` |

## Special Patterns

### Multiple Tests in One File

Each `<Fixture>` block becomes a separate `[Fact]` method:

```razor
@inherits BunitContext

@code {
[Fact]
public void Component_FirstScenario_ExpectedResult() { ... }

[Fact]
public void Component_SecondScenario_ExpectedResult() { ... }
}
```

### Tests with Services

```razor
@code {
[Fact]
public void Component_WithService_Works()
{
Services.AddSingleton<IMyService>(new FakeService());

var cut = Render(@<MyComponent />);
}
}
```

### Authentication Tests

```razor
@code {
[Fact]
public void SecureComponent_AuthenticatedUser_ShowsContent()
{
var authContext = this.AddTestAuthorization();
authContext.SetAuthorized("TestUser");
authContext.SetRoles("Admin");

var cut = Render(@<SecureComponent />);
}
}
```

### Tests Requiring New TestContext

For tests that need isolated context (e.g., multiple renders):

```razor
@code {
[Fact]
public void Component_MultipleRenders_WorksCorrectly()
{
using var ctx = new Bunit.TestContext();

var cut1 = ctx.Render(@<MyComponent Value="1" />);
var cut2 = ctx.Render(@<MyComponent Value="2" />);

cut1.Find("span").TextContent.ShouldBe("1");
cut2.Find("span").TextContent.ShouldBe("2");
}
}
```

## Quick Reference Table

| Old Pattern | New Pattern |
|-------------|-------------|
| `@inherits TestComponentBase` | `@inherits BunitContext` |
| `<Fixture Test="Name">` | Remove |
| `<ComponentUnderTest>` | Remove |
| `<SnapshotTest>` | `[Fact]` method with `MarkupMatches()` |
| `void Name(Fixture fixture)` | `[Fact] public void Name()` |
| `fixture.GetComponentUnderTest()` | `Render(@<Component />)` |
| `fixture.GetComponentUnderTest<T>()` | `Render<T>(@<Component />)` |

## Verification

After migrating a file, verify with:

```powershell
# Build check
dotnet build src/BlazorWebFormsComponents.Test --no-restore

# List discovered tests
dotnet test src/BlazorWebFormsComponents.Test --list-tests --filter "FullyQualifiedName~ComponentName"

# Run tests
dotnet test src/BlazorWebFormsComponents.Test --filter "FullyQualifiedName~ComponentName"
```

## Common Errors

| Error | Cause | Fix |
|-------|-------|-----|
| `CS0246: TestComponentBase not found` | Old inheritance | Change to `@inherits BunitContext` |
| `CS0103: Fixture does not exist` | Old wrapper element | Remove `<Fixture>` tags |
| `No tests discovered` | Missing `[Fact]` attribute | Add `[Fact]` to test methods |
| `Method must be public` | Private test method | Add `public` modifier |
Loading
Loading