Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main with documentation in stable #1369

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/site/docs/test-doubles/mocking-localizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ title: Mocking Localization via IStringLocalizer
---

<p>There are just two steps. First in your setup add the following:</p>

```csharp
TestContext.Services.AddLocalization();
```

<p>Then in your test code, when you need the localized string to compare, you write the following:</p>

```csharp
var localizer = ctx.Services.GetService<IStringLocalizer<SharedStrings>>();
```
```

<p>Where SharedStrings.cs (you can name this anything you want) that has the resource files such as `SharedStrings.en.resx`</p>
1 change: 1 addition & 0 deletions docs/site/docs/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
## [Emulating IJSRuntime](xref:emulating-ijsruntime)
## [Faking authorization](xref:faking-auth)
## [Mocking HttpClient](xref:mocking-httpclient)
## [Mocking Localizer](xref:mocking-localizer)
## [Faking PersistentComponentState](xref:faking-persistentcomponentstate)
## [Faking NavigationManager](xref:fake-navigation-manager)
## [Faking IWebAssemblyHostEnvironment](xref:fake-webassemblyhostenvironment)
Expand Down
Loading