public static TheoryData <IMvcCoreBuilder> MvcCoreBuilderExtensionsData() { var builder1 = new TestMvcCoreBuilder(); builder1.AddMvcLocalization(); var builder2 = new TestMvcCoreBuilder(); builder2.AddMvcLocalization(LanguageViewLocationExpanderFormat.SubFolder); var builder3 = new TestMvcCoreBuilder(); builder3.AddMvcLocalization(localizationOptionsSetupAction: l => l.ResourcesPath = "Resources"); var builder4 = new TestMvcCoreBuilder(); builder4.AddMvcLocalization( localizationOptionsSetupAction: l => l.ResourcesPath = "Resources", format: LanguageViewLocationExpanderFormat.SubFolder); return(new TheoryData <IMvcCoreBuilder>() { builder1, builder2, builder3, builder4 }); }
public void SetsLocalizationOptions_AsExpected() { // Arrange var builder = new TestMvcCoreBuilder(); // Act builder.AddMvcLocalization( localizationOptionsSetupAction: options => options.ResourcesPath = "TestResources"); // Assert var serviceProvider = builder.Services.BuildServiceProvider(); var actualOptions = serviceProvider.GetRequiredService <IOptions <LocalizationOptions> >(); Assert.Equal("TestResources", actualOptions.Value.ResourcesPath); }
public void SetsDataAnnotationsOptions_AsExpected() { // Arrange var builder = new TestMvcCoreBuilder(); var dataAnnotationLocalizerProvider = new Func <Type, IStringLocalizerFactory, IStringLocalizer>((type, factory) => { return(null); }); // Act builder.AddMvcLocalization( dataAnnotationsLocalizationOptionsSetupAction: options => options.DataAnnotationLocalizerProvider = dataAnnotationLocalizerProvider); // Assert var serviceProvider = builder.Services.BuildServiceProvider(); var actualOptions = serviceProvider.GetRequiredService <IOptions <MvcDataAnnotationsLocalizationOptions> >(); Assert.Same(dataAnnotationLocalizerProvider, actualOptions.Value.DataAnnotationLocalizerProvider); }