Skip to content

Commit 4580d33

Browse files
committed
Merge branch 'stable'
2 parents 7d58d85 + 1bb7f47 commit 4580d33

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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)