You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -349,10 +349,10 @@ The latest version of the library is availble on NuGet:
349
349
350
350
-**Added logging to TestRenderer.** To make it easier to understand the rendering life-cycle during a test, the `TestRenderer` will now log when ever it dispatches an event or renders a component (the log statements can be access by capturing debug logs in the test results, as mentioned above).
351
351
352
-
-**Added some of the Blazor frameworks end-2-end tests.** To get better test coverage of the many rendering scenarios supported by Blazor, the [ComponentRenderingTest.cs](https://github.com/dotnet/aspnetcore/blob/master/src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs) tests from the Blazor frameworks test suite has been converted from a Selenium to a bUnit. The testing style is very similar, so few changes was necessary to port the tests. The two test classes are here, if you want to compare:
352
+
-**Added some of the Blazor frameworks end-2-end tests.** To get better test coverage of the many rendering scenarios supported by Blazor, the [ComponentRenderingTest.cs](https://github.com/dotnet/aspnetcore/blob/main/src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs) tests from the Blazor frameworks test suite has been converted from a Selenium to a bUnit. The testing style is very similar, so few changes was necessary to port the tests. The two test classes are here, if you want to compare:
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ bUnit accept fixes and features! Here is what you should do when writing code fo
15
15
- Follow the coding conventions used in the project. In general, they align with the AspNetCore teams [coding guidelines](https://github.com/dotnet/aspnetcore/wiki/Engineering-guidelines#coding-guidelines).
16
16
- Add, remove, or delete unit tests to cover your changes. Make sure tests are specific to the changes you are making. Tests need to be provided for every bug/feature that is completed.
17
17
- All code changes should be done on the `DEV` branch, and pull requests should target it.
18
-
- All updates to the documentation, located under `./docs/` should be done on the `MASTER` branch **if** they are general in nature and not tied to a specific version. Changes to the documentation related to changes on the `DEV` branch should be submitted to the `DEV` branch.
18
+
- All updates to the documentation, located under `./docs/` should be done on the `main` branch **if** they are general in nature and not tied to a specific version. Changes to the documentation related to changes on the `DEV` branch should be submitted to the `DEV` branch.
19
19
- Any code or documentation you share with the bUnit projects should fall under the projects license agreement.
20
20
21
21
Here are some resources to help you get started on how to contribute code or new content.
Copy file name to clipboardExpand all lines: docs/site/docs/csharp-test-examples.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@
4
4
5
5
In the following examples, the terminology **component under test** (abbreviated CUT) is used to mean the component that is the target of the test. The examples below use the `Shouldly` assertion library as well. If you prefer not to use that just replace the assertions with the ones from your own favorite assertion library.
6
6
7
-
All examples can be found in the [Tests](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/Tests) folder in the [Sample project](https://github.com/egil/razor-components-testing-library/tree/master/sample/).
7
+
All examples can be found in the [Tests](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/Tests) folder in the [Sample project](https://github.com/egil/razor-components-testing-library/tree/main/sample/).
8
8
9
9
## Testing components without parameters
10
10
11
-
The following unit-tests verifies that the [Counter.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Pages/Counter.razor) component behaves correctly. Here is the source for the Counter component:
11
+
The following unit-tests verifies that the [Counter.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Pages/Counter.razor) component behaves correctly. Here is the source for the Counter component:
12
12
13
13
```razor
14
14
@page "/counter"
@@ -31,7 +31,7 @@ The following unit-tests verifies that the [Counter.razor](https://github.com/eg
31
31
}
32
32
```
33
33
34
-
The [CounterTest.cs](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/Tests/Pages/CounterTest.cs) looks like this:
34
+
The [CounterTest.cs](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/Tests/Pages/CounterTest.cs) looks like this:
35
35
36
36
```csharp
37
37
publicclassCounterTest : ComponentTestFixture
@@ -113,7 +113,7 @@ A few things worth noting about the tests above:
113
113
114
114
In the following tests we will pass regular parameters to a component under test, e.g. `[Parameter] public SomeType PropName { get; set; }` style properties, where `SomeType`**is not** a `RenderFragment` or a `EventCallback` type.
115
115
116
-
The component under test will be the [Aside.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Components/Aside.razor) component, which looks like this:
116
+
The component under test will be the [Aside.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Components/Aside.razor) component, which looks like this:
117
117
118
118
```cshtml
119
119
<aside @attributes="Attributes">
@@ -133,7 +133,7 @@ The component under test will be the [Aside.razor](https://github.com/egil/razor
133
133
}
134
134
```
135
135
136
-
The [AsideTest.cs](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/Tests/Components/AsideTest.cs) looks like this:
136
+
The [AsideTest.cs](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/Tests/Components/AsideTest.cs) looks like this:
137
137
138
138
```csharp
139
139
publicclassAsideTest : ComponentTestFixture
@@ -214,7 +214,7 @@ Some notes on `Test002` above:
214
214
215
215
## Testing components with child content
216
216
217
-
The [Aside.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Components/Aside.razor) component listed in the previous section also has a `ChildContent` parameter, so lets add a few tests that passes markup and components to it through that.
217
+
The [Aside.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Components/Aside.razor) component listed in the previous section also has a `ChildContent` parameter, so lets add a few tests that passes markup and components to it through that.
218
218
219
219
```csharp
220
220
publicclassAsideTest : ComponentTestFixture
@@ -283,7 +283,7 @@ public class AsideTest : ComponentTestFixture
283
283
284
284
## Testing components with `EventCallback` parameters
285
285
286
-
To show how to pass an `EventCallback` to a component under test, we will use the [ThemedButton.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Components/ThemedButton.razor), which looks like this:
286
+
To show how to pass an `EventCallback` to a component under test, we will use the [ThemedButton.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Components/ThemedButton.razor), which looks like this:
287
287
288
288
```cshtml
289
289
<button @onclick="HandleOnClick"
@@ -305,7 +305,7 @@ To show how to pass an `EventCallback` to a component under test, we will use th
305
305
}
306
306
```
307
307
308
-
The relevant part of [ThemedButtonTest.cs](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/Tests/Components/ThemedButtonTest.cs) looks like this:
308
+
The relevant part of [ThemedButtonTest.cs](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/Tests/Components/ThemedButtonTest.cs) looks like this:
@@ -336,7 +336,7 @@ public class ThemedButtonTest : ComponentTestFixture
336
336
337
337
## Testing components with cascading-value parameters
338
338
339
-
If a component under test accepts cascading values, like [ThemedButton.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Components/ThemedButton.razor) listed above, we can pass one or more cascading values to it like so:
339
+
If a component under test accepts cascading values, like [ThemedButton.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Components/ThemedButton.razor) listed above, we can pass one or more cascading values to it like so:
@@ -404,7 +404,7 @@ To make it easy to mock calls to JavaScript, the library comes with a `IJsRuntim
404
404
405
405
If you have more complex mocking needs, you could look to frameworks like [Moq](https://github.com/Moq) or [JustMock Lite](https://github.com/telerik/JustMockLite), which both work nicely with bUnit.
406
406
407
-
To help us test the Mock JSRuntime, we have the [WikiSearch.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Components/WikiSearch.razor) component, which looks like this:
407
+
To help us test the Mock JSRuntime, we have the [WikiSearch.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Components/WikiSearch.razor) component, which looks like this:
408
408
409
409
```cshtml
410
410
@inject IJSRuntime jsRuntime
@@ -432,7 +432,7 @@ To help us test the Mock JSRuntime, we have the [WikiSearch.razor](https://githu
432
432
}
433
433
```
434
434
435
-
The [WikiSearchTest.cs](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/Tests/Components/WikiSearchTest.cs) looks like this:
435
+
The [WikiSearchTest.cs](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/Tests/Components/WikiSearchTest.cs) looks like this:
436
436
437
437
```csharp
438
438
publicclassWikiSearchTest : ComponentTestFixture
@@ -499,7 +499,7 @@ public class WikiSearchTest : ComponentTestFixture
499
499
500
500
If you want to verify that a element reference (`ElementReference`) passed to a IJsRuntime.InvokeAsync call is references the expected DOM element, you can do so with the `ShouldBeElementReferenceTo()` assert helper.
501
501
502
-
For example, consider the [FocussingInput.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Components/FocussingInput.razor) component, which looks like this:
502
+
For example, consider the [FocussingInput.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Components/FocussingInput.razor) component, which looks like this:
503
503
504
504
```cshtml
505
505
@inject IJSRuntime jsRuntime
@@ -522,7 +522,7 @@ For example, consider the [FocussingInput.razor](https://github.com/egil/razor-c
522
522
}
523
523
```
524
524
525
-
The the [FocussingInputTest.cs](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/Tests/Components/FocussingInputTest.cs) looks like this:
525
+
The the [FocussingInputTest.cs](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/Tests/Components/FocussingInputTest.cs) looks like this:
@@ -552,15 +552,15 @@ The last line verifies that there was a single argument to the invocation, and v
552
552
553
553
## Testing components with injected dependencies
554
554
555
-
The demonstrate service injection, lets refactor the [FetchData.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Pages/FetchData.razor) component that comes with the default Razor app template, to make it more testable:
555
+
The demonstrate service injection, lets refactor the [FetchData.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Pages/FetchData.razor) component that comes with the default Razor app template, to make it more testable:
556
556
557
-
- Extract an interface from [WeatherForecastService](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Data/WeatherForecastService.cs), name it [IWeatherForecastService](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Data/IWeatherForecastService.cs), and have `FetchData` take a dependency on it.
557
+
- Extract an interface from [WeatherForecastService](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Data/WeatherForecastService.cs), name it [IWeatherForecastService](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Data/IWeatherForecastService.cs), and have `FetchData` take a dependency on it.
558
558
559
-
- Extract the `<table>` inside the `else` branch in the [FetchData.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Pages/FetchData.razor) component into its own component. Lets name it [ForecastDataTable](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Pages/FetchData.razor).
559
+
- Extract the `<table>` inside the `else` branch in the [FetchData.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Pages/FetchData.razor) component into its own component. Lets name it [ForecastDataTable](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Pages/FetchData.razor).
560
560
561
-
- In the [FetchData.razor](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Pages/FetchData.razor), pass the variable `forecasts` to the [ForecastDataTable](https://github.com/egil/razor-components-testing-library/tree/master/sample/src/Pages/FetchData.razor) component.
561
+
- In the [FetchData.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Pages/FetchData.razor), pass the variable `forecasts` to the [ForecastDataTable](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Pages/FetchData.razor) component.
562
562
563
-
Now we just need a [MockForecastService.cs](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/MockForecastService.cs). It looks like this:
563
+
Now we just need a [MockForecastService.cs](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/MockForecastService.cs). It looks like this:
@@ -570,7 +570,7 @@ internal class MockForecastService : IWeatherForecastService
570
570
}
571
571
```
572
572
573
-
With the mock in place, we can write the [FetchDataTest.cs](https://github.com/egil/razor-components-testing-library/tree/master/sample/tests/Tests/Pages/FetchDataTest.cs), which looks like this:
573
+
With the mock in place, we can write the [FetchDataTest.cs](https://github.com/egil/razor-components-testing-library/tree/main/sample/tests/Tests/Pages/FetchDataTest.cs), which looks like this:
Copy file name to clipboardExpand all lines: docs/site/docs/razor-test-examples.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@
4
4
5
5
In the following examples, the terminology **component under test** (abbreviated CUT) is used to mean the component that is the target of the test. The examples below use the `Shouldly` assertion library as well. If you prefer not to use that just replace the assertions with the ones from your own favorite assertion library.
6
6
7
-
All examples can be found in the [Tests](https://github.com/egil/bunit/tree/master/sample/tests/Tests) folder in the [Sample project](https://github.com/egil/bunit/tree/master/sample/).
7
+
All examples can be found in the [Tests](https://github.com/egil/bunit/tree/main/sample/tests/Tests) folder in the [Sample project](https://github.com/egil/bunit/tree/main/sample/).
8
8
9
9
## Examples
10
10
11
-
Here is a few examples that demonstrate how Razor test components can be used. More can be found in the [sample/tests/RazorComponentTests](https://github.com/egil/bunit/tree/master/sample/tests/RazorComponentTests) samples folder.
11
+
Here is a few examples that demonstrate how Razor test components can be used. More can be found in the [sample/tests/RazorComponentTests](https://github.com/egil/bunit/tree/main/sample/tests/RazorComponentTests) samples folder.
@@ -32,7 +32,7 @@ Here is a few examples that demonstrate how Razor test components can be used. M
32
32
}
33
33
```
34
34
35
-
This example shows how [ThemedElement.razor](https://github.com/egil/bunit/tree/master/sample/src/Components/ThemedElement.razor) can be tested with cascading values.
35
+
This example shows how [ThemedElement.razor](https://github.com/egil/bunit/tree/main/sample/src/Components/ThemedElement.razor) can be tested with cascading values.
36
36
37
37
```cshtml
38
38
<Fixture Test=MarkupPassedViaChildContent>
@@ -55,9 +55,9 @@ This example shows how [ThemedElement.razor](https://github.com/egil/bunit/tree/
55
55
}
56
56
```
57
57
58
-
This example shows how [ThemedButton.razor](https://github.com/egil/bunit/tree/master/sample/src/Components/ThemedButton.razor) can be tested with with child content, and how a `<Fragment>` can be used to specify the expected output.
58
+
This example shows how [ThemedButton.razor](https://github.com/egil/bunit/tree/main/sample/src/Components/ThemedButton.razor) can be tested with with child content, and how a `<Fragment>` can be used to specify the expected output.
59
59
60
-
Lets look at a more complex example, a test of the [TodoList.razor](https://github.com/egil/bunit/tree/master/sample/src/Pages/TodoList.razor) component:
60
+
Lets look at a more complex example, a test of the [TodoList.razor](https://github.com/egil/bunit/tree/main/sample/src/Pages/TodoList.razor) component:
0 commit comments