Skip to content

Commit b3dcf9e

Browse files
committed
Updates multiple docs
1 parent ffc897f commit b3dcf9e

26 files changed

Lines changed: 199 additions & 151 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@code
2+
{
3+
[Fact]
4+
public void Test()
5+
{
6+
// Arrange
7+
using var ctx = new TestContext();
8+
var cut = ctx.Render(@<ClickMe />);
9+
var buttonElement = cut.Find("button");
10+
11+
// Act
12+
buttonElement.Click();
13+
buttonElement.Click(detail: 3, ctrlKey: true);
14+
buttonElement.Click(new MouseEventArgs());
15+
16+
// Assert
17+
// ...
18+
}
19+
}

docs/samples/tests/xunit/ClickMeTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Bunit.Docs.Samples
77
public class ClickMeTest
88
{
99
[Fact]
10-
public void ClickingButtonWorks()
10+
public void Test()
1111
{
1212
// Arrange
1313
using var ctx = new TestContext();

docs/site/docs/code-of-conduct.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
uid: code-of-conduct
3-
title: Contributor Covenant Code of Conduct
3+
title: Contributor covenant code of conduct
44
---
55

6-
# Contributor Covenant Code of Conduct
6+
# Contributor covenant code of conduct
77

8-
## Our Pledge
8+
## Our pledge
99

1010
In the interests of fostering an open and welcoming environment, we as
1111
contributors and maintainers pledge to make our project and
@@ -14,7 +14,7 @@ size, disability, ethnicity, sexuality, gender identity and expression,
1414
level of experience, education, socio-economic status, nationality, personal
1515
appearance, race, or religion.
1616

17-
## Our Standards
17+
## Our standards
1818

1919
Examples of behavior that contribute towards creating a positive environment
2020
include:
@@ -35,7 +35,7 @@ Examples of unacceptable behavior by participants include:
3535
* Other conduct which could reasonably be considered inappropriate in a
3636
professional setting
3737

38-
## Our Responsibilities
38+
## Our responsibilities
3939

4040
Project maintainers are responsible for clarifying the standards of acceptable
4141
behavior and are expected to take appropriate and fair corrective action in

docs/site/docs/contribute.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ uid: contribute
33
title: Contribute
44
---
55

6-
# How to Contribute
6+
# How to contribute
77

88
One of the easiest ways to contribute is to participate in discussions on GitHub issues. You can also contribute by submitting pull requests with code changes.
99

10-
## General Feedback and Discussions
10+
## General feedback and discussions
1111
Start a discussion on the [bUnit discussion list](https://github.com/egil/bUnit/discussions).
1212

13-
## Bugs and Feature Requests
13+
## Bugs and feature requests
1414
For bugs or feature requests, log a new issue on the [issues list](https://github.com/egil/bunit/issues). Be sure to use the right template.
1515

16-
## Contributing Code and Content
16+
## Contributing code and content
1717

1818
bUnit accepts fixes and features. Here is what you should do when writing code for bUnit:
1919

@@ -28,18 +28,18 @@ Here are some resources to help you get started on how to contribute code or new
2828
* ["Help wanted" issues](https://github.com/egil/bunit/labels/help%20wanted) - these issues are up for grabs if you want to create a fix. To do this, simply comment on the issue you want to fix.
2929
* ["Good first issue" issues](https://github.com/egil/bunit/labels/good%20first%20issue) - these are good for newcomers. Good first issues are small, usually require just a few hours of work, and do not require a deep technical knowledge of bUnit. This is a good place to start if you want to become familiar with bUnit’s inner workings and maybe take on bigger issues later.
3030

31-
### Identifying the Scale of a Contribution
31+
### Identifying the scale of a contribution
3232

3333
If you would like to contribute to bUnit, first identify the scale of what you would like to contribute. If it is small (grammar/spelling or a bug fix), feel free to start working on a fix. If you are submitting a feature or substantial code contribution, please discuss it with us first.
3434

3535
You might also read these two blogs posts on contributing code: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik. These blog posts highlight good open source collaboration etiquette and help align expectations between you and us.
3636

3737
All code submissions will be rigorously reviewed and tested, and only those that meet a high bar for both quality and design/roadmap appropriateness will be merged into the source.
3838

39-
### Submitting a Pull Request
39+
### Submitting a pull request
4040

4141
If you don't know what a pull request is, read this article: https://help.github.com/articles/using-pull-requests. Make sure the repository can build and all tests pass. It is also a good idea to familiarize yourself with the project workflow and our coding conventions.
4242

43-
## Code of Conduct
43+
## Code of conduct
4444

4545
See <xref:code-of-conduct>

docs/site/docs/external-resources.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ title: External Resources
66
# Presentations, guides, articles, tutorials, and blog posts
77
Here is a list of some web content that covers bUnit. If you produce something you think can be useful to bUnit's users, feel free to add it to this page and send a pull request.
88

9-
### Presentations
10-
11-
- **[Testing Blazor Components - session from .NET Conf - Focus on Blazor](https://youtu.be/5d-uIxx1cUE)**
12-
Content is based on beta-5.1 of bUnit.
13-
149
### Podcasts/Twitch/YouTube/Live coding
1510

11+
- **[Test Driving the Blazing Pizza Workshop with bUnit (multiple videos)](https://youtube.com/playlist?list=PL2LoDmbC1g20uJjUwPGQxpQjdnmpMqV0t)**
12+
Content is based on 1.0.0 of bUnit.
13+
1614
- **[.NET Rocks! - Testing Blazor Apps with Egil Hansen](https://www.dotnetrocks.com/?show=1690)**
1715
Content is based on beta-7 of bUnit.
1816

@@ -21,7 +19,12 @@ Here is a list of some web content that covers bUnit. If you produce something y
2119

2220
- **[Blazor StateHasChanged: Blazor Component Unit Testing with Egil Hansen](https://www.youtube.com/watch?v=x-zzcwHdZOk&t=211)**
2321
Content is based on beta-5.1 of bUnit.
24-
22+
23+
### Presentations
24+
25+
- **[Testing Blazor Components - session from .NET Conf - Focus on Blazor](https://youtu.be/5d-uIxx1cUE)**
26+
Content is based on beta-5.1 of bUnit.
27+
2528
### Articles and blog posts
2629

2730
- **[bUnit for Blazor and How to Integrate it in Azure Pipeline](https://www.syncfusion.com/blogs/post/bunit-for-blazor-and-how-to-integrate-it-in-azure-pipeline.aspx) by Ramkumar Shanmugam**
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
uid: getting-started
3-
title: Getting Started with bUnit
3+
title: Getting started with bUnit
44
---
55

6-
# Getting Started with bUnit
6+
# Getting started with bUnit
77

88
To start writing tests for Blazor components, first set up a test project and then you can start adding tests.
99

@@ -14,10 +14,10 @@ The *basic* getting started topics are as follows:
1414

1515
The *next level* topics are:
1616

17-
1. **[Providing different types of input](xref:providing-input)** to a component under test in C# based tests, e.g. passing parameters or injecting services.
17+
1. **[Providing different types of input](xref:providing-input)** to a component under test, e.g. passing parameters or injecting services.
1818
2. **[Verifying output in various ways](xref:verification)** from a component under test, e.g. inspecting the rendered markup.
1919
3. **[Mocking dependencies](xref:test-doubles)** a component under test has, e.g. the `IJsRuntime` or `HttpClient`.
2020

21-
## Getting Help
21+
## Getting help
2222

2323
Can't figure out how to write a test for a testing scenario? Do you have a testing scenario that is hard to write or cannot be written elegantly with bUnit? Have you found a bug in bUnit? Head over to [bUnit’s discussion forum](https://github.com/egil/bUnit/discussions) to ask a question, give feedback, or suggest a new feature. Alternatively, join [bUnits Gitter channel](https://gitter.im/egil/bunit) and let us know. There are no stupid questions - all are welcome!

docs/site/docs/getting-started/writing-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Then methods like <xref:Bunit.TestContext.RenderComponent``1(System.Action{Bunit
230230
> For example, `var cut = ctx.RenderComponent<HelloWorld>();`
231231
> becomes `var cut = RenderComponent<HelloWorld>();`.
232232
233-
## Further Reading
233+
## Further reading
234234

235235
With the basics out of the way, next we will look at how to pass parameters and inject services into our component under test. After that, we will cover ways we can verify the outcome of a rendering in more detail
236236

docs/site/docs/interaction/awaiting-async-state.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
uid: awaiting-async-state
3-
title: Awaiting an Asynchronous State Change in a Component Under Test
3+
title: Awaiting an asynchronous state change in a component under test
44
---
55

6-
# Awaiting an Asynchronous State Change
6+
# Awaiting an asynchronous state change
77

88
A test can fail if a component performs asynchronous renders. This may be due to a reason such as waiting for an asynchronous operation to complete before continuing its render life-cycle. For example, if a component is waiting for an async web service to return data to it in the `OnInitializedAsync()` life-cycle method before rendering it to the render tree.
99

@@ -13,7 +13,7 @@ bUnit comes with two methods that help to deal with this issue: the [`WaitForSta
1313

1414
Let's start by taking a look at the `WaitForState` method in more detail.
1515

16-
## Waiting for State Using `WaitForState`
16+
## Waiting for state using `WaitForState`
1717

1818
The [`WaitForState(Func<Boolean>, TimeSpan?)`](xref:Bunit.RenderedFragmentWaitForHelperExtensions.WaitForState(Bunit.IRenderedFragmentBase,System.Func{System.Boolean},System.Nullable{System.TimeSpan})) method can be used to block and wait in a test method, until the provided predicate returns true or the timeout is reached. (The default timeout is one second.)
1919

@@ -38,7 +38,7 @@ This is what happens in the test:
3838
> [!WARNING]
3939
> The wait predicate and an assertion should not verify the same thing. Instead, use the `WaitForAssertion(...)` method covered on the <xref:async-assertion> page instead.
4040
41-
### Controlling Wait Timeout
41+
### Controlling wait timeout
4242

4343
The timeout, which defaults to one second, can be controlled by passing a `TimeSpan` as the second argument to the `WaitForState()` method, e.g.:
4444

docs/site/docs/interaction/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
uid: interaction
3-
title: Interacting with a Component Under Test
3+
title: Interacting with a component under test
44
---
55

6-
# Interacting with a Component Under Test
6+
# Interacting with a component under test
77

88
This section covers the various ways to interact with a component under test, e.g. trigger event handlers. This &mdash; and more &mdash; is covered in the following sub sections:
99

docs/site/docs/interaction/trigger-event-handlers.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
uid: trigger-event-handlers
3-
title: Triggering Event Handlers in Components
3+
title: Triggering event handlers in components
44
---
55

6-
# Triggering Event Handlers in Components
6+
# Triggering event handlers in components
77

88
Blazor makes it possible to bind many event handlers to elements in a Blazor component using the `@onXXXX` syntax, e.g. `@onclick="MyClickHandler"`.
99

@@ -27,7 +27,7 @@ To use these, first find the element in the component under test where the event
2727

2828
The following section demonstrates how to do this...
2929

30-
## Invoking an Event Handler on an Element
30+
## Invoking an event handler on an element
3131

3232
To invoke an event handler on an element, first find the element in the component under test, and then call the desired event dispatch helper method.
3333

@@ -39,11 +39,11 @@ To trigger the `@onclick` `ClickHandler` event handler method in the `<ClickMe>`
3939

4040
# [C# test code](#tab/csharp)
4141

42-
[!code-csharp[ClickMeTest.cs](../../../samples/tests/xunit/ClickMeTest.cs?range=12-23&highlight=7-9)]
42+
[!code-csharp[ClickMeTest.cs](../../../samples/tests/xunit/ClickMeTest.cs?range=9-25&highlight=10-13)]
4343

4444
# [Razor test code](#tab/razor)
4545

46-
[!code-cshtml[ClickMeTest.razor](../../../samples/tests/razor/ClickMeTest.razor?highlight=17-19)]
46+
[!code-cshtml[ClickMeTest.razor](../../../samples/tests/razor/ClickMeTest.razor?highlight=12-14)]
4747

4848
***
4949

0 commit comments

Comments
 (0)