Skip to content

Commit f022007

Browse files
bUnitBotmartincostellolinkdotnet
authored
Update main with documentation in stable (#1541)
* docs: Fix heading (#1537) * Fix heading Fix heading not rendering correctly. * Fix heading Be gone, crazy space. * docs: Fix AddFakePersistentComponentState examples (Fixes #1539) (#1540) --------- Co-authored-by: Martin Costello <[email protected]> Co-authored-by: Steven Giesel <[email protected]>
1 parent 3d03d6f commit f022007

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/site/docs/test-doubles/faking-persistentcomponentstate.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ bUnit comes with fake version of the `PersistentComponentState` type in Blazor t
1212
To use the fake `PersistentComponentState` in bUnit, call the `AddFakePersistentComponentState` extension method on `TestContext`:
1313

1414
```csharp
15-
var fakeState = AddFakePersistentComponentState();
15+
var fakeState = this.AddFakePersistentComponentState();
1616
```
1717

1818
Calling `AddFakePersistentComponentState` returns a `FakePersistentComponentState` type, which has three methods; one to persist data, one to get persisted data, and one that triggers any "OnPersisting" callbacks added to the `PersistentComponentState`.
1919

2020
To add data to the `PersistentComponentState` before running a test, i.e. to verify that a component uses the persisted state, use the `Persist` method:
2121

2222
```csharp
23-
var fakeState = AddFakePersistentComponentState();
23+
var fakeState = this.AddFakePersistentComponentState();
2424
var key = "STATE KEY";
2525
var data = ...; // data to persist
2626
@@ -31,7 +31,7 @@ fakeState.Persist(key, data);
3131
To trigger a callback registered with the `PersistentComponentState.RegisterOnPersisting` method, use the `TriggerOnPersisting` method on `FakePersistentComponentState`:
3232

3333
```csharp
34-
var fakeState = AddFakePersistentComponentState();
34+
var fakeState = this.AddFakePersistentComponentState();
3535

3636
// render component
3737
@@ -41,7 +41,7 @@ fakeState.TriggerOnPersisting();
4141
To check if data has been persisted, use the `TryTake` method:
4242

4343
```csharp
44-
var fakeState = AddFakePersistentComponentState();
44+
var fakeState = this.AddFakePersistentComponentState();
4545
var key = "STATE KEY";
4646

4747
// render component, call TriggerOnPersisting
@@ -95,7 +95,7 @@ To test that the `<FetchData>` component uses persisted weather data instead of
9595

9696
```csharp
9797
// Arrange
98-
var fakeState = AddFakePersistentComponentState();
98+
var fakeState = this.AddFakePersistentComponentState();
9999

100100
// Persist a single weather forecast with a temperature of 42
101101
fakeState.Persist("weather-data", new [] { new WeatherForecast { Temperature = 42 } });
@@ -111,7 +111,7 @@ To test that the `<FetchData>` component correctly persists weather data when it
111111

112112
```csharp
113113
// Arrange
114-
var fakeState = AddFakePersistentComponentState();
114+
var fakeState = this.AddFakePersistentComponentState();
115115
var cut = RenderComponent<FetchData>();
116116

117117
// Act - trigger the FetchData components PersistForecasts method

0 commit comments

Comments
 (0)