File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,15 @@ title: Mocking Localization via IStringLocalizer
4
4
---
5
5
6
6
<p >There are just two steps. First in your setup add the following:</p >
7
+
7
8
``` csharp
8
9
TestContext .Services .AddLocalization ();
9
10
```
11
+
10
12
<p >Then in your test code, when you need the localized string to compare, you write the following:</p >
13
+
11
14
``` csharp
12
15
var localizer = ctx .Services .GetService <IStringLocalizer <SharedStrings >>();
13
- ```
16
+ ```
17
+
14
18
<p >Where SharedStrings.cs (you can name this anything you want) that has the resource files such as `SharedStrings.en.resx`</p >
Original file line number Diff line number Diff line change 25
25
## [ Emulating IJSRuntime] ( xref:emulating-ijsruntime )
26
26
## [ Faking authorization] ( xref:faking-auth )
27
27
## [ Mocking HttpClient] ( xref:mocking-httpclient )
28
+ ## [ Mocking Localizer] ( xref:mocking-localizer )
28
29
## [ Faking PersistentComponentState] ( xref:faking-persistentcomponentstate )
29
30
## [ Faking NavigationManager] ( xref:fake-navigation-manager )
30
31
## [ Faking IWebAssemblyHostEnvironment] ( xref:fake-webassemblyhostenvironment )
You can’t perform that action at this time.
0 commit comments