Skip to content

Commit 11e3c53

Browse files
committed
Tweaks to docs, small fix in code. Bump to beta-2
1 parent 9ff70f4 commit 11e3c53

27 files changed

+79
-38
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Blazor Components Testing Library
88
A testing library for Blazor Components. You can easily define components under test in C# or Razor syntax, it has intelligent HTML diffing/comparison logic. You can easily interact with and inspect components, trigger event handlers, provide cascading values, inject services, mock `IJsRuntime`, and perform snapshot testing.
99

10-
This framework's goal is to make it easy to write _comprehensive, stable unit tests_ for Blazor Components/Razor Components. To see how, head to the documentation pages:
10+
This library's goal is to make it easy to write _comprehensive, stable unit tests_ for Blazor Components/Razor Components. To see how, head to the documentation pages:
1111

1212
1. [Introduction](docs)
1313
2. [Getting started](docs/#getting-started)

docs/csharp-examples.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ All examples can be found in the [Tests](../sample/tests/Tests) folder in the [S
1818

1919
## Creating new test classes
2020

21-
All test classes are currently expected to inherit from `ComponentTestFixture`, which contains all the logic for rendering components and correctly dispose of renderers and HTML parsers after each test. For example:
21+
All test classes are currently expected to inherit from `ComponentTestFixture`, which contains all the logic for rendering components and correctly dispose of renderers and HTML parsers after each test. The example below includes the needed using statements as well:
2222

2323
```csharp
24+
using Egil.RazorComponents.Testing;
25+
using Egil.RazorComponents.Testing.Asserting;
26+
using Egil.RazorComponents.Testing.EventDispatchExtensions;
27+
using Xunit;
28+
2429
public class MyComponentTest : ComponentTestFixture
2530
{
2631
[Fact]

docs/razor-examples.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ You will also need to import a few namespaces to make asserting and mocking poss
2020
```cshtml
2121
@inherits TestComponentBase
2222
@using Egil.RazorComponents.Testing
23+
@using Egil.RazorComponents.Testing.Asserting
2324
@using Egil.RazorComponents.Testing.EventDispatchExtensions
2425
@using Xunit @*or e.g. Shouldly*@
2526
```

docs/readme.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Blazor Component Testing
22

3-
This framework's goal is to make it easy to write _comprehensive, stable unit tests_ for Blazor Components/Razor Components.
3+
This library's goal is to make it easy to write _comprehensive, stable unit tests_ for Blazor Components/Razor Components.
44

55
1. [Introduction](#introduction)
66
2. [Getting started](#getting-started)
@@ -10,7 +10,7 @@ This framework's goal is to make it easy to write _comprehensive, stable unit te
1010

1111
## Introduction
1212

13-
**To make tests easy to write**, the framework provides a few different ways of define the **component under test** (CUT):
13+
**To make tests easy to write**, the library provides a few different ways of define the **component under test** (CUT):
1414

1515
1. Render components from C# code via the `RenderComponent<TComponent>(params...)` method, that allow you to easily pass component parameters, cascading values, event callbacks to the component.
1616

@@ -56,14 +56,16 @@ Examples are split into three sections, one for each style/declaration type.
5656
Examples of tests written in Razor files using Razor code to declare/arrange the component under test and expected HTML, and C# code for driving the test.
5757
3. [Snapshot tests](snapshot-examples.md)
5858
Examples of snapshot tests written in Razor code, where the component under test and expected output is declared in Razor syntax and automatically verified.
59+
4. []
5960

6061
## References
6162

6263
The following sections are planned but not done yet. A lot of the public methods are however documented, so view the documentation in the source code for now.
6364

6465
Upcoming sections:
6566

66-
1. [Built-in assertions](#)
67+
1. [Built-in assertions](#)
68+
1.1 [Controlling HTML diffing](#)
6769
2. [Component creation and rendering](#)
6870
3. [Semantic HTML diffing options](#)
6971

sample/tests/Tests/Components/AsideTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using Egil.RazorComponents.Testing.Asserting;
67
using Egil.RazorComponents.Testing.SampleApp.Components;
78
using Xunit;
89

sample/tests/Tests/Components/FocussingInputTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using Egil.RazorComponents.Testing.Asserting;
67
using Egil.RazorComponents.Testing.SampleApp.Components;
78
using Xunit;
89

sample/tests/Tests/Components/PassingChildContentTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using Egil.RazorComponents.Testing.Asserting;
67
using Egil.RazorComponents.Testing.SampleApp.Components;
78
using Shouldly;
89
using Xunit;

sample/tests/Tests/Components/ThemedButtonTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using Microsoft.AspNetCore.Components;
7+
using Egil.RazorComponents.Testing.Asserting;
78
using Egil.RazorComponents.Testing.SampleApp.Components;
89
using Xunit;
910
using Shouldly;

sample/tests/Tests/Components/TodoItemTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Egil.RazorComponents.Testing.EventDispatchExtensions;
1+
using Egil.RazorComponents.Testing.Asserting;
2+
using Egil.RazorComponents.Testing.EventDispatchExtensions;
23
using Egil.RazorComponents.Testing.SampleApp.Components;
34
using Egil.RazorComponents.Testing.SampleApp.Data;
45
using Microsoft.AspNetCore.Components;

sample/tests/Tests/Components/TodoListTest.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
using AngleSharp.Dom;
1+
using Shouldly;
2+
using AngleSharp.Dom;
3+
using Egil.RazorComponents.Testing.Asserting;
24
using Egil.RazorComponents.Testing.EventDispatchExtensions;
35
using Egil.RazorComponents.Testing.SampleApp.Components;
46
using Egil.RazorComponents.Testing.SampleApp.Data;
57
using Microsoft.AspNetCore.Components;
68
using Microsoft.JSInterop;
7-
using Shouldly;
89
using System;
910
using System.Collections.Generic;
1011
using System.Linq;
@@ -118,7 +119,8 @@ public void Test005()
118119
cut.Find("input").Change(taskValue);
119120
cut.Find("form").Submit();
120121

121-
createdTask.ShouldNotBeNull().Text.ShouldBe(taskValue);
122+
createdTask.ShouldNotBeNull();
123+
createdTask?.Text.ShouldBe(taskValue);
122124
}
123125

124126
[Fact(DisplayName = "When add task form is submitted with no text OnAddingTodo is not called")]

0 commit comments

Comments
 (0)