Skip to content

Commit 1bb7f47

Browse files
authored
docs: add content to mocking-localizer.md
* Update mocking-localizer.md * Update mocking-localizer.md implemented suggestions
1 parent 83ef62f commit 1bb7f47

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/site/docs/test-doubles/mocking-localizer.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ uid: mocking-localizer
33
title: Mocking Localization via IStringLocalizer
44
---
55

6-
# Mocking Localization via `IStringLocalizer`
6+
<p>There are just two steps. First in your setup add the following:</p>
7+
```csharp
8+
TestContext.Services.AddLocalization();
9+
```
10+
<p>Then in your test code, when you need the localized string to compare, you write the following:</p>
11+
```csharp
12+
var localizer = ctx.Services.GetService<IStringLocalizer<SharedStrings>>();
13+
```
14+
<p>Where SharedStrings.cs (you can name this anything you want) that has the resource files such as `SharedStrings.en.resx`</p>

0 commit comments

Comments
 (0)