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
44---
55
66<p >There are just two steps. First in your setup add the following:</p >
7+
78``` csharp
89TestContext .Services .AddLocalization ();
910```
11+
1012<p >Then in your test code, when you need the localized string to compare, you write the following:</p >
13+
1114``` csharp
1215var localizer = ctx .Services .GetService <IStringLocalizer <SharedStrings >>();
13- ```
16+ ```
17+
1418<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 2525## [ Emulating IJSRuntime] ( xref:emulating-ijsruntime )
2626## [ Faking authorization] ( xref:faking-auth )
2727## [ Mocking HttpClient] ( xref:mocking-httpclient )
28+ ## [ Mocking Localizer] ( xref:mocking-localizer )
2829## [ Faking PersistentComponentState] ( xref:faking-persistentcomponentstate )
2930## [ Faking NavigationManager] ( xref:fake-navigation-manager )
3031## [ Faking IWebAssemblyHostEnvironment] ( xref:fake-webassemblyhostenvironment )
You can’t perform that action at this time.
0 commit comments