React to Options change

This commit is contained in:
Ryan Brandenburg 2018-01-22 12:41:33 -08:00 committed by Pranav K
parent ebdb3c650a
commit ea14942525
2 changed files with 155 additions and 303 deletions

View File

@ -5,74 +5,74 @@
<PropertyGroup Label="Package Versions"> <PropertyGroup Label="Package Versions">
<BenchmarkDotNetPackageVersion>0.10.11</BenchmarkDotNetPackageVersion> <BenchmarkDotNetPackageVersion>0.10.11</BenchmarkDotNetPackageVersion>
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview1-15678</InternalAspNetCoreSdkPackageVersion> <InternalAspNetCoreSdkPackageVersion>2.1.0-preview1-15678</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAntiforgeryPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreAntiforgeryPackageVersion> <MicrosoftAspNetCoreAntiforgeryPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreAntiforgeryPackageVersion>
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion> <MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreAuthenticationCorePackageVersion> <MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
<MicrosoftAspNetCoreAuthenticationPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreAuthenticationPackageVersion> <MicrosoftAspNetCoreAuthenticationPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreAuthenticationPackageVersion>
<MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreAuthorizationPolicyPackageVersion> <MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion> <MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
<MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion> <MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion>
<MicrosoftAspNetCoreCookiePolicyPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreCookiePolicyPackageVersion> <MicrosoftAspNetCoreCookiePolicyPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreCookiePolicyPackageVersion>
<MicrosoftAspNetCoreCorsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreCorsPackageVersion> <MicrosoftAspNetCoreCorsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreCorsPackageVersion>
<MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion> <MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion>
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreDiagnosticsPackageVersion> <MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreDiagnosticsPackageVersion>
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreHostingAbstractionsPackageVersion> <MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreHostingPackageVersion> <MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreHtmlAbstractionsPackageVersion> <MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>
<MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreHttpExtensionsPackageVersion> <MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreHttpExtensionsPackageVersion>
<MicrosoftAspNetCoreHttpPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreHttpPackageVersion> <MicrosoftAspNetCoreHttpPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreHttpPackageVersion>
<MicrosoftAspNetCoreJsonPatchPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreJsonPatchPackageVersion> <MicrosoftAspNetCoreJsonPatchPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreJsonPatchPackageVersion>
<MicrosoftAspNetCoreLocalizationPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreLocalizationPackageVersion> <MicrosoftAspNetCoreLocalizationPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreLocalizationPackageVersion>
<MicrosoftAspNetCoreLocalizationRoutingPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreLocalizationRoutingPackageVersion> <MicrosoftAspNetCoreLocalizationRoutingPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreLocalizationRoutingPackageVersion>
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion> <MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
<MicrosoftAspNetCoreRangeHelperSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreRangeHelperSourcesPackageVersion> <MicrosoftAspNetCoreRangeHelperSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreRangeHelperSourcesPackageVersion>
<MicrosoftAspNetCoreRazorDesignPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreRazorDesignPackageVersion> <MicrosoftAspNetCoreRazorDesignPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreRazorDesignPackageVersion>
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreRazorRuntimePackageVersion> <MicrosoftAspNetCoreRazorRuntimePackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreRazorRuntimePackageVersion>
<MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion> <MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion>
<MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion> <MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion>
<MicrosoftAspNetCoreResponseCachingPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreResponseCachingPackageVersion> <MicrosoftAspNetCoreResponseCachingPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreResponseCachingPackageVersion>
<MicrosoftAspNetCoreRoutingAbstractionsPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreRoutingAbstractionsPackageVersion> <MicrosoftAspNetCoreRoutingAbstractionsPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreRoutingAbstractionsPackageVersion>
<MicrosoftAspNetCoreRoutingPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreRoutingPackageVersion> <MicrosoftAspNetCoreRoutingPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreRoutingPackageVersion>
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreServerIISIntegrationPackageVersion> <MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreServerKestrelPackageVersion> <MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreSessionPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreSessionPackageVersion> <MicrosoftAspNetCoreSessionPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreSessionPackageVersion>
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreStaticFilesPackageVersion> <MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreStaticFilesPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreTestHostPackageVersion> <MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreTestingPackageVersion> <MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.1.0-preview1-28124</MicrosoftAspNetCoreWebUtilitiesPackageVersion> <MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.1.0-preview1-28137</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
<MicrosoftAspNetWebApiClientPackageVersion>5.2.4-preview1</MicrosoftAspNetWebApiClientPackageVersion> <MicrosoftAspNetWebApiClientPackageVersion>5.2.4-preview1</MicrosoftAspNetWebApiClientPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>2.6.1</MicrosoftCodeAnalysisCSharpPackageVersion> <MicrosoftCodeAnalysisCSharpPackageVersion>2.6.1</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>2.6.1</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion> <MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>2.6.1</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisRazorPackageVersion>2.1.0-preview1-28124</MicrosoftCodeAnalysisRazorPackageVersion> <MicrosoftCodeAnalysisRazorPackageVersion>2.1.0-preview1-28137</MicrosoftCodeAnalysisRazorPackageVersion>
<MicrosoftExtensionsCachingMemoryPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsCachingMemoryPackageVersion> <MicrosoftExtensionsCachingMemoryPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsCachingMemoryPackageVersion>
<MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion> <MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsConfigurationJsonPackageVersion> <MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsConfigurationJsonPackageVersion>
<MicrosoftExtensionsConfigurationPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsConfigurationPackageVersion> <MicrosoftExtensionsConfigurationPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsConfigurationPackageVersion>
<MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion> <MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion>
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsDependencyInjectionPackageVersion> <MicrosoftExtensionsDependencyInjectionPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsDependencyInjectionPackageVersion>
<MicrosoftExtensionsDependencyModelPackageVersion>2.1.0-preview2-25711-01</MicrosoftExtensionsDependencyModelPackageVersion> <MicrosoftExtensionsDependencyModelPackageVersion>2.1.0-preview2-25711-01</MicrosoftExtensionsDependencyModelPackageVersion>
<MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsDiagnosticAdapterPackageVersion> <MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsDiagnosticAdapterPackageVersion>
<MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsFileProvidersAbstractionsPackageVersion> <MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>
<MicrosoftExtensionsFileProvidersCompositePackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsFileProvidersCompositePackageVersion> <MicrosoftExtensionsFileProvidersCompositePackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsFileProvidersCompositePackageVersion>
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsFileProvidersEmbeddedPackageVersion> <MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>
<MicrosoftExtensionsFileSystemGlobbingPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsFileSystemGlobbingPackageVersion> <MicrosoftExtensionsFileSystemGlobbingPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsFileSystemGlobbingPackageVersion>
<MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion> <MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion>
<MicrosoftExtensionsLocalizationPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsLocalizationPackageVersion> <MicrosoftExtensionsLocalizationPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsLocalizationPackageVersion>
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsLoggingAbstractionsPackageVersion> <MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsLoggingConsolePackageVersion> <MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsLoggingDebugPackageVersion> <MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsLoggingDebugPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsLoggingPackageVersion> <MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsLoggingTestingPackageVersion> <MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion> <MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>
<MicrosoftExtensionsOptionsPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsOptionsPackageVersion> <MicrosoftExtensionsOptionsPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsOptionsPackageVersion>
<MicrosoftExtensionsPrimitivesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsPrimitivesPackageVersion> <MicrosoftExtensionsPrimitivesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsPrimitivesPackageVersion>
<MicrosoftExtensionsPropertyActivatorSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsPropertyActivatorSourcesPackageVersion> <MicrosoftExtensionsPropertyActivatorSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsPropertyActivatorSourcesPackageVersion>
<MicrosoftExtensionsPropertyHelperSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsPropertyHelperSourcesPackageVersion> <MicrosoftExtensionsPropertyHelperSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsPropertyHelperSourcesPackageVersion>
<MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsSecurityHelperSourcesPackageVersion> <MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsSecurityHelperSourcesPackageVersion>
<MicrosoftExtensionsWebEncodersPackageVersion>2.1.0-preview1-28124</MicrosoftExtensionsWebEncodersPackageVersion> <MicrosoftExtensionsWebEncodersPackageVersion>2.1.0-preview1-28137</MicrosoftExtensionsWebEncodersPackageVersion>
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion> <MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview1-26115-03</MicrosoftNETCoreApp21PackageVersion> <MicrosoftNETCoreApp21PackageVersion>2.1.0-preview1-26115-03</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNetHttpHeadersPackageVersion>2.1.0-preview1-28124</MicrosoftNetHttpHeadersPackageVersion> <MicrosoftNetHttpHeadersPackageVersion>2.1.0-preview1-28137</MicrosoftNetHttpHeadersPackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion> <MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
<MoqPackageVersion>4.7.49</MoqPackageVersion> <MoqPackageVersion>4.7.49</MoqPackageVersion>
<NewtonsoftJsonBsonPackageVersion>1.0.1</NewtonsoftJsonBsonPackageVersion> <NewtonsoftJsonBsonPackageVersion>1.0.1</NewtonsoftJsonBsonPackageVersion>

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -30,30 +31,9 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal
setupAction: null); setupAction: null);
// Assert // Assert
Assert.Collection(collection, AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(HtmlLocalizerFactory));
service => AssertContainsSingle(collection, typeof(IHtmlLocalizer<>), typeof(HtmlLocalizer<>));
{ AssertContainsSingle(collection, typeof(IViewLocalizer), typeof(ViewLocalizer));
Assert.Equal(typeof(IConfigureOptions<RazorViewEngineOptions>), service.ServiceType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizerFactory), service.ServiceType);
Assert.Equal(typeof(HtmlLocalizerFactory), service.ImplementationType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizer<>), service.ServiceType);
Assert.Equal(typeof(HtmlLocalizer<>), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IViewLocalizer), service.ServiceType);
Assert.Equal(typeof(ViewLocalizer), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
});
} }
[Fact] [Fact]
@ -61,264 +41,136 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal
{ {
// Arrange // Arrange
var collection = new ServiceCollection(); var collection = new ServiceCollection();
var testEncoder = new HtmlTestEncoder();
// Act // Act
collection.Add(ServiceDescriptor.Singleton(typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory))); collection.Add(ServiceDescriptor.Singleton(typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory)));
collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>))); collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>)));
collection.Add(ServiceDescriptor.Transient(typeof(IViewLocalizer), typeof(TestViewLocalizer))); collection.Add(ServiceDescriptor.Transient(typeof(IViewLocalizer), typeof(TestViewLocalizer)));
collection.Add(ServiceDescriptor.Singleton(typeof(HtmlEncoder), testEncoder));
MvcLocalizationServices.AddMvcViewLocalizationServices( MvcLocalizationServices.AddMvcViewLocalizationServices(
collection, collection,
LanguageViewLocationExpanderFormat.Suffix, LanguageViewLocationExpanderFormat.Suffix,
setupAction: null); setupAction: null);
// Assert AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory));
Assert.Collection(collection, AssertContainsSingle(collection, typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>));
service => AssertContainsSingle(collection, typeof(IViewLocalizer), typeof(TestViewLocalizer));
{
Assert.Equal(typeof(IHtmlLocalizerFactory), service.ServiceType);
Assert.Equal(typeof(TestHtmlLocalizerFactory), service.ImplementationType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizer<>), service.ServiceType);
Assert.Equal(typeof(TestHtmlLocalizer<>), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IViewLocalizer), service.ServiceType);
Assert.Equal(typeof(TestViewLocalizer), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(HtmlEncoder), service.ServiceType);
Assert.Same(testEncoder, service.ImplementationInstance);
},
service =>
{
Assert.Equal(typeof(IConfigureOptions<RazorViewEngineOptions>), service.ServiceType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
});
} }
[Fact] private void AssertContainsSingle(
public void AddCustomLocalizers_AfterAddLocalizationServices_AddsNeededServices() IServiceCollection services,
Type serviceType,
Type implementationType)
{ {
// Arrange var matches = services
var collection = new ServiceCollection(); .Where(sd =>
var htmlEncoder = new HtmlTestEncoder(); sd.ServiceType == serviceType &&
sd.ImplementationType == implementationType)
.ToArray();
collection.Configure<RazorViewEngineOptions>(options => if (matches.Length == 0)
{ {
options.ViewLocationExpanders.Add(new CustomPartialDirectoryViewLocationExpander()); Assert.True(
}); false,
$"Could not find an instance of {implementationType} registered as {serviceType}");
// Act }
MvcLocalizationServices.AddMvcViewLocalizationServices( else if (matches.Length > 1)
collection, {
LanguageViewLocationExpanderFormat.Suffix, Assert.True(
setupAction: null); false,
$"Found multiple instances of {implementationType} registered as {serviceType}");
}
collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>)));
collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer), typeof(TestViewLocalizer)));
collection.Add(ServiceDescriptor.Singleton(typeof(HtmlEncoder), htmlEncoder));
// Assert
Assert.Collection(collection,
service =>
{
Assert.Equal(typeof(IConfigureOptions<RazorViewEngineOptions>), service.ServiceType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IConfigureOptions<RazorViewEngineOptions>), service.ServiceType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizerFactory), service.ServiceType);
Assert.Equal(typeof(HtmlLocalizerFactory), service.ImplementationType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizer<>), service.ServiceType);
Assert.Equal(typeof(HtmlLocalizer<>), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IViewLocalizer), service.ServiceType);
Assert.Equal(typeof(ViewLocalizer), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizer<>), service.ServiceType);
Assert.Equal(typeof(TestHtmlLocalizer<>), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizer), service.ServiceType);
Assert.Equal(typeof(TestViewLocalizer), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(HtmlEncoder), service.ServiceType);
Assert.Same(htmlEncoder, service.ImplementationInstance);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
});
} }
[Fact] public class TestViewLocalizer : IViewLocalizer
public void AddLocalizationServicesWithLocalizationOptions_AddsNeededServices()
{ {
// Arrange public LocalizedHtmlString this[string name]
var collection = new ServiceCollection(); {
get
{
throw new NotImplementedException();
}
}
// Act public LocalizedHtmlString this[string name, params object[] arguments]
MvcLocalizationServices.AddMvcViewLocalizationServices( {
collection, get
LanguageViewLocationExpanderFormat.Suffix, {
options => options.ResourcesPath = "Resources"); throw new NotImplementedException();
}
}
// Assert public LocalizedString GetString(string name)
Assert.Collection(collection, {
service => throw new NotImplementedException();
{ }
Assert.Equal(typeof(IConfigureOptions<RazorViewEngineOptions>), service.ServiceType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizerFactory), service.ServiceType);
Assert.Equal(typeof(HtmlLocalizerFactory), service.ImplementationType);
Assert.Equal(ServiceLifetime.Singleton, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IHtmlLocalizer<>), service.ServiceType);
Assert.Equal(typeof(HtmlLocalizer<>), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
},
service =>
{
Assert.Equal(typeof(IViewLocalizer), service.ServiceType);
Assert.Equal(typeof(ViewLocalizer), service.ImplementationType);
Assert.Equal(ServiceLifetime.Transient, service.Lifetime);
});
}
}
public class TestViewLocalizer : IViewLocalizer public LocalizedString GetString(string name, params object[] arguments)
{ {
public LocalizedHtmlString this[string name] throw new NotImplementedException();
{ }
get
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
{
throw new NotImplementedException();
}
public IHtmlLocalizer WithCulture(CultureInfo culture)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public LocalizedHtmlString this[string name, params object[] arguments] public class TestHtmlLocalizer<HomeController> : IHtmlLocalizer<HomeController>
{ {
get public LocalizedHtmlString this[string name]
{
get
{
throw new NotImplementedException();
}
}
public LocalizedHtmlString this[string name, params object[] arguments]
{
get
{
throw new NotImplementedException();
}
}
public LocalizedString GetString(string name)
{
throw new NotImplementedException();
}
public LocalizedString GetString(string name, params object[] arguments)
{
throw new NotImplementedException();
}
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
{
throw new NotImplementedException();
}
public IHtmlLocalizer WithCulture(CultureInfo culture)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public LocalizedString GetString(string name) public class TestHtmlLocalizerFactory : IHtmlLocalizerFactory
{ {
throw new NotImplementedException(); public IHtmlLocalizer Create(Type resourceSource)
}
public LocalizedString GetString(string name, params object[] arguments)
{
throw new NotImplementedException();
}
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
{
throw new NotImplementedException();
}
public IHtmlLocalizer WithCulture(CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class TestHtmlLocalizer<HomeController> : IHtmlLocalizer<HomeController>
{
public LocalizedHtmlString this[string name]
{
get
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
}
public LocalizedHtmlString this[string name, params object[] arguments] public IHtmlLocalizer Create(string baseName, string location)
{
get
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public LocalizedString GetString(string name)
{
throw new NotImplementedException();
}
public LocalizedString GetString(string name, params object[] arguments)
{
throw new NotImplementedException();
}
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
{
throw new NotImplementedException();
}
public IHtmlLocalizer WithCulture(CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class TestHtmlLocalizerFactory : IHtmlLocalizerFactory
{
public IHtmlLocalizer Create(Type resourceSource)
{
throw new NotImplementedException();
}
public IHtmlLocalizer Create(string baseName, string location)
{
throw new NotImplementedException();
}
}
public class CustomPartialDirectoryViewLocationExpander : IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
throw new NotImplementedException();
}
public void PopulateValues(ViewLocationExpanderContext context)
{
}
} }
} }