Skip to content

Commit

Permalink
docs: add content to mocking-localizer.md
Browse files Browse the repository at this point in the history
* Update mocking-localizer.md

* Update mocking-localizer.md

implemented suggestions
  • Loading branch information
DavidThielen authored Nov 13, 2023
1 parent 83ef62f commit 1bb7f47
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/site/docs/test-doubles/mocking-localizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ uid: mocking-localizer
title: Mocking Localization via IStringLocalizer
---

# 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>

0 comments on commit 1bb7f47

Please sign in to comment.