aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Mock/Services
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-10-24 20:15:58 +0800
committerGitHub <noreply@github.com>2019-10-24 20:15:58 +0800
commit4ab69665f26aaa59bad8684e6b801b4c4cf900cd (patch)
tree7ca5010a06829cc5fadea1ea17ae72d082fc344c /Timeline.Tests/Mock/Services
parent21de8da2feab19d3fbc392e71bf0dcec25ec8d6b (diff)
parent2bc4c701f9cdff1fdd11a5736c33a5818fbae3e9 (diff)
downloadtimeline-4ab69665f26aaa59bad8684e6b801b4c4cf900cd.tar.gz
timeline-4ab69665f26aaa59bad8684e6b801b4c4cf900cd.tar.bz2
timeline-4ab69665f26aaa59bad8684e6b801b4c4cf900cd.zip
Merge pull request #50 from crupest/refactor
Refactor : A Huge Step
Diffstat (limited to 'Timeline.Tests/Mock/Services')
-rw-r--r--Timeline.Tests/Mock/Services/TestClock.cs10
-rw-r--r--Timeline.Tests/Mock/Services/TestStringLocalizerFactory.cs25
2 files changed, 25 insertions, 10 deletions
diff --git a/Timeline.Tests/Mock/Services/TestClock.cs b/Timeline.Tests/Mock/Services/TestClock.cs
index 0082171e..6671395a 100644
--- a/Timeline.Tests/Mock/Services/TestClock.cs
+++ b/Timeline.Tests/Mock/Services/TestClock.cs
@@ -1,5 +1,3 @@
-using Microsoft.AspNetCore.Mvc.Testing;
-using Microsoft.Extensions.DependencyInjection;
using System;
using Timeline.Services;
@@ -14,12 +12,4 @@ namespace Timeline.Tests.Mock.Services
return MockCurrentTime.GetValueOrDefault(DateTime.Now);
}
}
-
- public static class TestClockWebApplicationFactoryExtensions
- {
- public static TestClock GetTestClock<T>(this WebApplicationFactory<T> factory) where T : class
- {
- return factory.Server.Host.Services.GetRequiredService<IClock>() as TestClock;
- }
- }
}
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);
+ }
+ }
+}