aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Mock/Services
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-10-21 13:41:46 +0800
committer杨宇千 <crupest@outlook.com>2019-10-21 13:41:46 +0800
commit5e64e3385ae8eb9b877c032418da9e5086d50a06 (patch)
tree705580fda162d3a2667f288ddb8092e8fba09703 /Timeline.Tests/Mock/Services
parent38cef20cd509648d50e289cd4c7ec4a772031b12 (diff)
downloadtimeline-5e64e3385ae8eb9b877c032418da9e5086d50a06.tar.gz
timeline-5e64e3385ae8eb9b877c032418da9e5086d50a06.tar.bz2
timeline-5e64e3385ae8eb9b877c032418da9e5086d50a06.zip
...
Diffstat (limited to 'Timeline.Tests/Mock/Services')
-rw-r--r--Timeline.Tests/Mock/Services/MockStringLocalizer.cs31
-rw-r--r--Timeline.Tests/Mock/Services/TestStringLocalizerFactory.cs25
2 files changed, 25 insertions, 31 deletions
diff --git a/Timeline.Tests/Mock/Services/MockStringLocalizer.cs b/Timeline.Tests/Mock/Services/MockStringLocalizer.cs
deleted file mode 100644
index 7729d56c..00000000
--- a/Timeline.Tests/Mock/Services/MockStringLocalizer.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Microsoft.Extensions.Localization;
-using System.Collections.Generic;
-using System.Globalization;
-
-namespace Timeline.Tests.Mock.Services
-{
- public class MockStringLocalizer : IStringLocalizer
- {
- private const string mockKey = "MOCK_KEY";
- private const string mockString = "THIS IS A MOCK LOCALIZED STRING.";
-
- public LocalizedString this[string name] => new LocalizedString(name, mockString);
-
- public LocalizedString this[string name, params object[] arguments] => new LocalizedString(name, mockString);
-
- public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
- {
- yield return new LocalizedString(mockKey, mockString);
- }
-
- public IStringLocalizer WithCulture(CultureInfo culture)
- {
- return this;
- }
- }
-
- public class MockStringLocalizer<T> : MockStringLocalizer, IStringLocalizer<T>
- {
-
- }
-}
diff --git a/Timeline.Tests/Mock/Services/TestStringLocalizerFactory.cs b/Timeline.Tests/Mock/Services/TestStringLocalizerFactory.cs
new file mode 100644
index 00000000..4084dd8f
--- /dev/null
+++ b/Timeline.Tests/Mock/Services/TestStringLocalizerFactory.cs
@@ -0,0 +1,25 @@
+using Microsoft.Extensions.Localization;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.Extensions.Options;
+
+namespace Timeline.Tests.Mock.Services
+{
+ internal static class TestStringLocalizerFactory
+ {
+ internal static IStringLocalizerFactory Create()
+ {
+ return new ResourceManagerStringLocalizerFactory(
+ Options.Create(new LocalizationOptions()
+ {
+ ResourcesPath = "Resource"
+ }),
+ NullLoggerFactory.Instance
+ );
+ }
+
+ internal static IStringLocalizer<T> Create<T>(this IStringLocalizerFactory factory)
+ {
+ return new StringLocalizer<T>(factory);
+ }
+ }
+}